“exclude_matches” in manifest.json does nothing?

…衆ロ難τιáo~ 提交于 2019-11-28 03:59:05

问题


I'm having a problem controlling what pages my content scripts are injected into. The chrome extension developer guide specifies that I can use an "exclude_matches" directive in my manifest.json to exclude certain pages from injection.

However, this doesn't seem to have any effect. My content script still executes on pages that I have specified as ignored.

I have put the steps to reproduce in a Gist. The code is also available on Github.

Any ideas what I'm doing wrong?

manifest.json

{
  "name": "Testing Extension",
  "version": "1.0",
  "description": "Test the chrome extensions exclude_matches.",
  "content_scripts": [{
    "matches": ["http://*/*", "https://*/*"],
    "exclude_matches": ["http://news.ycombinator.com/"],
    "js": ["content.js"]
  }]
}

content.js

console.log("hello from the content script");

回答1:


This is Bug #100106. exclude_matches do not function properly.

To solve the problem, use exclude_globs instead of exclude_matches.

Also, your exclude_matches rule does only match http://news.ycombinator.com/.
Suffice the pattern with an asterisk to match the whole site: http://news.ycombinator.com/*.

See also: Match patterns.



来源:https://stackoverflow.com/questions/9687322/exclude-matches-in-manifest-json-does-nothing

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