See comments in code below:
chrome.browserAction.onClicked.addListener(function(tab) {
// ################# This works without any problems
chrome.tabs.executeScript(tabId, {
code: '!!window.LoadedFlag'
}, function (hasContentJs) { ... });
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
// ################# This throws error:
// Unchecked runtime.lastError while running tabs.executeScript:
// Cannot access contents of url "http://localhost:3000/". Extension manifest must request permission to access this host.
chrome.tabs.executeScript(tabId, {
code: '!!window.LoadedFlag'
}, function (hasContentJs) { ... });
I'm I not allowed to do chrome.tabs.executeScript
in a callback to specifically chrome.tabs.onUpdated.addListener
?
My use-case is that I need to run a startup script on every page refresh but only if my extension has been enabled.
manifest.json:
"permissions" : [
"activeTab"
"tabs",
"http://*/*",
"https://*/*"
],