Does content_scripts matches “chrome-extension://*/*” work?

匿名 (未验证) 提交于 2019-12-03 02:11:02

问题:

I want to run a content script on an iframe with a chrome-extension:// URL. I added a line to my manifest.json that I copied out of the documentation http://code.google.com/chrome/extensions/match_patterns.html

 chrome-extension://*/* 

But when I reload my extension I get an alert:

Could not load extension from '/work/sirius/extension'.  Invalid value for 'content_scripts[2].matches[0]': Invalid scheme. 

Any idea how to get this to worK?

回答1:

I'm having the exact same problem, look at the API http://code.google.com/chrome/extensions/match_patterns.html it says clearly that they accept chrome-extension://*/* yet they don't.

They need to update the API so as not to confuse people.



回答2:

No. Only ftp:, file:, http: and https: can be matched by a content script declaration.

Invalid URL patterns at any of the matches and exclude_matches fields are rejected (generating an error when trying to load the extension).

Invalid patterns at the permissions option in the manifest file are ignored.

If you want to run a script on a tab from your extension, use chrome.extension.getViews in your background script. Even better, design your extension's pages such that they effectively communicate with each other (example).



回答3:

It seems that Chrome authors have silently removed the ability for content scripts to be injected into chrome-extension: pages. Documentation still says that it works and even contains examples with chrome-extension: scheme but actually it doesn't work. So now only http:, https: and ftp: work "from the box" and file: can work if user of your extension has enabled this on Extensions (chrome://extensions/) page.

Update: now documentation referred above is updated and says nothing about ability to inject content scripts to chrome-extension: pages.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!