Unchecked runtime.lastError when starting tabs.executeScript: cannot access contents url "data: text / html, chromewebdata"

I get this error:

extensions::lastError:133 Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url "data:text/html,chromewebdata". Extension manifest must request permission to access this host. 

I get this error after turning off the Internet so that I can take action when the page loading failed (due to heavy load) or on the Internet.

I checked all such questions and almost the same , but still could not get it to work. Another very similar one with the comment that Chrome does not allow capturing internal pages

My permissions are as follows:

 "permissions": [ "tabs","unlimitedStorage", "notifications", "history", "activeTab", "storage", "webRequest", "webRequestBlocking", "*://*/*", "http://*/*", "https://*/*" ], 

I get an error when running this code:

 chrome.tabs.executeScript(null, {file: "showbacklink.js"}); 

or

  chrome.tabs.executeScript(details.tabId, {file: "showbacklink.js"}); 

where details.tabId is the active tab.

What am I missing?

Edited manifest. json

 { "name": "", "options_page": "options.html", "description": "", "version": "1.0", "icons": { "16": "icons/logo16.png", "48": "icons/logo48.png", "128": "icons/logo128.png" }, "permissions": [ "tabs","unlimitedStorage", "notifications", "history", "activeTab", "storage", "webRequest", "webRequestBlocking", "http://*/*", "https://*/*" ], "background": { "scripts": [ "showbacklink.js", "client_server_common.js", "common.js", "background.js" ], "persistent": true }, "content_security_policy": "script-src 'self'; object-src 'self'", "manifest_version": 2, "content_scripts": [ { "run_at": "document_end", "all_frames": true, "matches": ["https://*/*"], "css": [//REMOVED], "js": [ //other files REMOVED "myscript.js", ] }, ], "web_accessible_resources": [ //REMOVED ] } 
+1
google-chrome-extension
source share
1 answer

Indeed, an โ€œOfflineโ€ page or any other error page is treated as an internal Chrome page, not its โ€œoriginalโ€ URL. Therefore, you cannot enter into such pages to change them for security reasons. Imagine for a moment that the extension will be able to interact with SSL warning pages - you really do not want this.

If your goal is to provide some kind of alternative error page, you need to connect the listener to such navigation errors and redirect to your page.

I would recommend looking at webNavigation and webRequest API.

+2
source share

All Articles