" exclude_matches"在manifest.json中什么都不做? [英] "exclude_matches" in manifest.json does nothing?

查看:166
本文介绍了" exclude_matches"在manifest.json中什么都不做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在控制我的内容脚本注入哪些页面时遇到问题。 Chrome扩展开发者指南指定我可以在我的我的排除匹配指令中使用exclude_matches指令 manifest.json 将某些页面从注入中排除。



然而,这似乎没有任何效果。我的内容脚本仍然在我已指定为被忽略的页面上执行。



我已将在Gist中重现的步骤。该代码也是在Github上可用



任何想法我做错了?



manifest.json

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

content.js

  console.log(来自内容脚本的hello); 


解决方案

这是 Bug#100106 exclude_matches 无法正常运行。



要解决该问题,请使用 exclude_globs 而不是 exclude_matches

另外,您的 exclude_matches 规则只匹配 http://news.ycombinator.com/

足够模式一个星号以匹配整个网站: http://news.ycombinator.com/*



另请参阅:匹配模式


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");

解决方案

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.

这篇关于" exclude_matches"在manifest.json中什么都不做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆