问题
I've enabled "chrome://flags/#extensions-on-chrome-urls" which should allow me to create extensions that can run on chrome:// sites. When I try to unpack my extension, however, it fails with the error message: "Invalid value for 'content_scripts[0].matches[0]': Invalid scheme." I don't believe my script.js is a problem since the unpacking doesn't fail when I replace the "chrome://extensions" part with an http or https sites. Any help would be greatly appreciated, does anyone know a fix?
manifest.json:
{
"name": "Does something on chrome://extensions",
"version": "1.2",
"description": "Read the name",
"manifest_version": 2,
"browser_action": {
"default_title": "Ext",
"default_popup": "popup.html"
},
"content_scripts": [ {
"matches": ["chrome://extensions"],
"js": ["script.js"]
} ]
}
回答1:
Note: This is an undocumented feature and may fail without warning in the future.
chrome://extensions
is an invalid match pattern. You cannot omit the path component, so at the very least you should use "chrome://extensions/*"
.
This does however not work either, because the actual URL is chrome://chrome/extensions
. Or, if you are specifically interested in the page that shows the list of extensions, chrome://extensions-frame
.
To run a content script at the extensions page, use --extensions-on-chrome-urls
and:
"content_scripts": [{
"matches": ["chrome://chrome/extensions*"],
"js": ["script.js"]
}]
or (the frame that lists all extensions, i.e. what you see when you visit chrome://extensions
):
"content_scripts": [{
"matches": ["chrome://extensions-frame/*"],
"all_frames": true,
"js": ["script.js"]
}]
来源:https://stackoverflow.com/questions/41747941/chrome-invalid-scheme