Ok, let me make a few changes to your manifest and background pages.
manifest.json
"browser_action": { "default_icon": "off.png", "default_title": "icon" },
This will do off.png by default. Regarding the icon section, read the docs to find out what it's used for, but for now, just delete it completely. Also delete what you have in the contentScripts section. If you want to enter it programmatically, then there is no need to list it in the manifest.
Further, some changes to your background page will make it cleaner:
background.js
var toggle = false; chrome.browserAction.onClicked.addListener(function(tab) { toggle = !toggle; if(toggle){ chrome.browserAction.setIcon({path: "on.png", tabId:tab.id}); chrome.tabs.executeScript(tab.id, {file:"SCRIPT.user.js"}); } else{ chrome.browserAction.setIcon({path: "off.png", tabId:tab.id}); chrome.tabs.executeScript(tab.id, {code:"alert()"}); } });
Beardfist
source share