Hello,
I think your problem is very simple. I`m not sure but I think you can only execute "chrome.tabs.executeScript(null,{"preenche()"});" from the background page. One option is to use "chrome.extension.getBackgroundPage().chrome.tabs.executeScript(null,{"preenche()"});". It will probably work, but if it doesn't just use this:
//Background Page
<html>
<script>
function click(){
chrome.tabs.executeScript(null,{"preenche()"});
}
</script>
</html>
// popup.html
<html>
<head>
<script type="text/javascript">
function click() {
chrome.extension.getBackgroundPage().click()
window.close();
}
</script>
</head>
<body>
<input type="button" onclick="click();" value="preencher 0.0.1" />
</body>
</html>
If you are not really adding anything else to the popup you can just use an event listener in the background page and no popup:
//Background Page
<html>
<script>
//React when a browser action's icon is clicked.
chrome.browserAction.onClicked.addListener(function(tab) {click()});
function click(){
chrome.tabs.executeScript(null,{"preenche()"});
}
</script>
</html>