At the moment i'm using a timeout like this:
function injectScript() {
chrome.tabs.executeScript({
file: "inject.js"
});
}
chrome.pageAction.onClicked.addListener((tab) => {
injectScript();
setTimeout(() => {
doSomething(tab)
}, 1000);
});
I want to replace the setTimeout
to a better alternative.
function injectScript() {
chrome.tabs.executeScript({
file: "inject.js"
},
()=>{
doSomething(tab)
});
}