问题
Here is my mainfest.json
:
"content_scripts": [ {
"all_frames": true,
"css": [ "css/event.css" ],
"matches": [ "\u003Call_urls>" ],
"run_at": "document_start"
}
but I cannot find content script in the chrome://extensions/
page
help!!!
回答1:
You can do it on your PC by enabling chrome://flags/#extensions-on-chrome-urls
and adding the necessary url, chrome://extensions/
, into "matches"
in manifest.json but such extension won't be possible to install on a normal browser due to an invalid scheme error.
To avoid the fatal error, don't use manifest.json to inject the content script/style, do it manually in the background or popup script via chrome.tabs.insertCSS
or chrome.tabs.executeScript
:
chrome://flags
: enableExtensions on chrome:// URLs
flagmanifest.json:
"permissions": ["chrome://*/*", "tabs"], "background": { "scripts": ["background.js"] },
background.js:
var chromeURLstylable; chrome.permissions.contains({origins: ["chrome://*/*"], permissions: ["tabs"]}, function(state) { chromeURLstylable = state; console.log("chrome:// urls support", state); if (chromeURLstylable) { chrome.tabs.onUpdated.addListener(function(tabId, info, tab) { if (info.status == "loading" && tab.url.indexOf("chrome://") == 0) { chrome.tabs.insertCSS({ file: "style.css", runAt: "document_start", allFrames: true }); } }); } });
Beware of possible problems submitting such extension to the Chrome Webstore.
来源:https://stackoverflow.com/questions/33891245/access-extensions-in-the-chrome-extensions-page