Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"exclude_matches" in manifest.json does nothing?

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");
like image 394
David Tuite Avatar asked Mar 13 '12 15:03

David Tuite


1 Answers

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.

like image 137
Rob W Avatar answered Sep 18 '22 07:09

Rob W