Answer the question
In order to leave comments, you need to log in
Is it possible to do script injection on click using chrome extension?
I am writing an extension for chrome, I need to insert a script into the page with content like:
setInterval(function(){//code}, 30000); . That is, the code should be executed regardless of whether the application is open or not. What does the injection have to be done on the click of a button in the extension, is it possible? And if so, how?
Answer the question
In order to leave comments, you need to log in
Read .
The point is that when the button is clicked, a message is sent
var port = chrome.runtime.connect({name: "ClickButton"});
port.postMessage();
chrome.runtime.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
setInterval(function(){//code}, 30000);
}
}
chrome.runtime.onConnect.addListener(function(port) {
setInterval(function(){//code}, 30000);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question