2

I created a T-Rex run bot using JavaScript. Now, I want to turn it into an extension. I want to run some codes if a browser tab turned into No Internet page. I got that content script can't do it for sure so I'm using a background script. I want to run some JS codes inside the tab that failed connecting the web and said No Internet.
Here's my manifest file

{
"manifest_version": 2,
"name": "TREX",
"version": "0.2"
,
"background": {
"scripts": ["back.js"],
"persistent": false
},
"permissions": [
        "webNavigation","<all_urls>","tabs","http://*/*","https://*/*"
    ]
}

My back.js

chrome.webNavigation.onErrorOccurred.addListener(function (details) {
chrome.tabs.executeScript(details.tabId,{code:"SOME LINES OF CODE HERE!!!"});

});

But It does not work! Am I using the commands in the correct syntax? Or maybe I'm missing some permissions?
PS It has an error on the chrome://extention page:

Unchecked runtime.lastError: Cannot access contents of url "chrome error://chromewebdata/". Extension manifest must request permission to access this host.

Sdrf1445
  • 147
  • 2
  • 2
  • 9
  • Define doesn't work. Is any error thrown? Anything in the console? How about the page at `chrome://extensions` - does it report any problems with your unpacked extension? – Mitya Apr 08 '20 at 09:42
  • @Utkanos Unchecked runtime.lastError: Cannot access contents of url "chrome-error://chromewebdata/". Extension manifest must request permission to access this host. What should I do? – Sdrf1445 Apr 08 '20 at 09:51
  • Some pages don't allow extensions - particularly any beginning with `chrome://`. https://stackoverflow.com/questions/37093152/unchecked-runtime-lasterror-while-running-tabs-executescript-cannot-access-cont – Mitya Apr 08 '20 at 09:57
  • @Utkanos You are saying that it is something impossible? I cannot turn that bot into an extension? – Sdrf1445 Apr 08 '20 at 10:08
  • 1
    As the error message says you can't inject code into errored pages. There's a flag you can set for your local extension, see the [linked topic](https://stackoverflow.com/questions/19042857/can-you-access-chrome-pages-from-an-extension). – wOxxOm Apr 08 '20 at 10:21

0 Answers0