我在控制将我的内容脚本注入(inject)哪些页面时遇到问题。 chrome extension developer guide指定我可以在我的 manifest.json
中使用“exclude_matches”指令从注入(inject)中排除某些页面。
但是,这似乎没有任何效果。我的内容脚本仍然在我指定为忽略的页面上执行。
我已经把 steps to reproduce in a Gist .代码也是available on Github .
任何想法我做错了什么?
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"]
}]
}
内容.js
console.log("hello from the content script");
最佳答案
这是Bug #100106 . exclude_matches
不能正常工作。
要解决此问题,请使用 exclude_globs
而不是 exclude_matches
.
另外,您的 exclude_matches
规则只匹配 http://news.ycombinator.com/
.
使用 来满足模式星号 匹配整个网站:http://news.ycombinator.com/*
.
另见:Match patterns .
关于google-chrome - manifest.json 中的 "exclude_matches"什么都不做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9687322/