I'd like to use JavaScript to add a search bar for chrome://extensions/
page, so I created a file called test.user.js, and write scripts in it:
// ==UserScript==
// @name chromeex
// @namespace chromeex
// @version v1.0
/* @reason
* just a test
* @end
*/
// @match chrome://extensions/
//
// ==/UserScript==
(function(){
alert("haha");
}());
But when I load it in Chrome, it said Invalid header, finally I found out that it's @match chrome://extensions/
that cause the error. Is there a walkaround for this?
A Chrome extension won't execute in the chrome://extensions/
directory or on the Chrome Web Store or a few other important areas for security.
One easy way to think of it is that if an extension had access to the DOM in your Chrome Extensions page it could remove your ability to uninstall it, which could be pretty nasty for many users. You may want to look at the chrome.management API, however, if you want to build something outside the Extensions page to be able to search through a user's extensions.
chrome
itself is not a permitted scheme, which is why you are getting an invalid scheme error. Here's what Google has to say about it:
A match pattern is essentially a URL that begins with a permitted scheme (http
, https
, file
, or ftp
), and that can contain '*'
characters. The special pattern <all_urls>
matches any URL that starts with a permitted scheme.
So by definition chrome
as a scheme will not work no matter what. Think of it not as just another web page, but a part of Chrome's UI.
I think, that page is not "ordinary" web page, it's high security area, where you can't mess around with userscripts. That is what plugins are for.
You cannot inject a Content Script / User Script in chrome://extensions/ due to security reasons. You can use the Extension Management API page to create your own extension management extension.