I am exploring ways to enable users to toggle a Chrome content script with the click of a button. It appears that using chrome.browserAction is the most efficient method for achieving this.
However, when I include the following code snippet:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {file: "script.js"});
});
in the background.html file, the script runs regardless of whether the button is clicked or not. The rest of the script functions correctly. The only issue lies with the browser button. Any insights on where the problem might lie? Thank you!