I'm trying to inject a script into the webpage when a button in the extension option menu is clicked. Injection -
document.getElementById("button_").addEventListener("click", function(){
alert("Injecting") ;
chrome.tabs.executeScript({
file: 'script.js'
});
});
However the function that I'm trying to run in script.js , foo() is not running. I'm trying to run it via-
window.onload= function(){
foo() ;
}
However this does not work . How do I get foo() to run?
Note- It has to run as an injected script