Reputation: 9067
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://*/*"
],
Upvotes: 1
Views: 1053
Reputation: 9067
sorry, just a simple misstake of reloading the extension. When making changes to the .js files, it's enough just to hit cmd+r
to reload it. It looks like when changing the manifest.json
I needed to go to chrome://extentions
and do a harder reload. Thanks to Rob W for the tip in the comment and link to better alternatives.
Upvotes: 1