David Tuite
David Tuite

Reputation: 22643

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

Upvotes: 6

Views: 5426

Answers (1)

Rob W
Rob W

Reputation: 349032

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.

Upvotes: 9

Related Questions