Reputation: 147
I have a script that executes a script, but in my case the script only runs when I click on the icon: I need in my case to automatically run/inject the script when the pages loads.
My code:
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
Upvotes: 0
Views: 54
Reputation: 147
So after looking more closer i found this solution:
chrome.tabs.onUpdated.addListener(
function ( tabId, changeInfo, tab )
{
if ( changeInfo.status === "complete" )
{
chrome.tabs.executeScript({
file: 'inject.js'
});
}
});
Upvotes: 1