There are two errors:
A key browser_action does not have the script, just browser_style , default_icon , default_title , default_popup, theme_icons in>.
The file is calling the onload method, after the page is already loaded.
To run a code by clicking the extension icon, you need to call a pop html.
Manifest.json
{
"name": "SGIR - Extensão",
"manifest_version": 2,
"version": "1.0",
"description": "Preencher formulários",
"browser_action": {
"default_popup": "popup.html"
},
"permissions": [
"tabs",
"https://www.google.com.br/"
],
"content_scripts": [{
"js": ["funcao.js"],
"matches": ["https://www.google.com.br/"]
}]
}
function.js
var ni = document.getElementById("lst-ib");
ni.value = "Alguma coisa!";
popup.html
<!doctype html>
<html>
<head>
<script src="funcao2.js"></script>
</head>
<body></body>
</html>
funcao2.js
chrome.tabs.query({active:true,windowType:"normal", currentWindow: true},function(tab){
chrome.tabs.executeScript(tab[0].id, {
"file": "funcao.js"
});
})
Add the permission to the URL you want to modify. It can be regex.