1

I'm having a few problems with my chrome extension I'm developing. It appears that the extension does not have access to any given tab in chrome. This leads me to believe that it is a problem with either the JS or manifest file. Both will be posted below for reference.

JS:

chrome.tabs.query({
active: true,
lastFocusedWindow: true
},
function(array_of_Tabs) {
  tab = array_of_Tabs[0];
  chrome.tabs.executeScript(tab.id, {code: "document.body.innerHTML = document.body.innerHTML.replace('hello', 'hi');"});
});

Manifest File:

{
   "manifest_version": 2,

  "name": "Extension",
  "description": "My extension",
  "version": "1.0",
    "permissions": [
    "activeTab"
  ],
  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
},
  "background": {
    "scripts": ["popup.js"]  
  }
}

I've tried to give the manifest every permission I can think of. I've attempted giving it access to all domains and subdomains via permissions such as these:

permissions": ["http://*/*", "https://*/*"]

But no matter what I do it is always throwing this error in the console and extensions window:

Unchecked runtime.lastError while running tabs.executeScript: Cannot access <insert tab url open in chrome here> 

Thanks much for the help, have a good one -0xified

0xified
  • 21
  • 2
  • What user action invokes the JS? – Sean Adams Jul 08 '14 at 04:33
  • Right now I don't have it set to anything automatic, you just have to click the icon to activate it. – 0xified Jul 08 '14 at 05:11
  • I believe you have this error on any url. This question is wrongly marked as duplicated. I have the same problem, sometimes it works as it's intended to do, sometimes this error show up: I refresh the page and it works fine. Sometimes I have to refresh the page many times. – Alejandro Silvestri Jan 13 '15 at 14:31

0 Answers0