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.