google-chrome - manifest.json 中的 "exclude_matches"什么都不做?

标签 google-chrome google-chrome-extension google-chrome-devtools

我在控制将我的内容脚本注入(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/

相关文章:

google-chrome-devtools - Chrome 是否仍支持 SPDY?

javascript - 延迟长时间运行的计时器任务以提高滚动平滑度

java - 无法在最新的谷歌浏览器上访问 https api

javascript - 我可以在 JavaScript 的回调函数中为变量赋值吗?

android - Service Worker client.openWindow 从 list 中打开 start_url 而不是请求的 URL

c++ - 如何使用为 Native Client(NaCl) 移植的库?

javascript - Chrome 扩展程序 - 进入全屏模式会将页面背景颜色变为黑色

networking - "Natural"大小是加载的大小吗?

javascript - Chrome 扩展内容安全策略指令错误

asp.net-mvc - asp.net mvc 应用程序中的 SameSite 属性