简体   繁体   中英

Content script pattern matching

I'm looking for a way to match certain patterns on a url path that should invoke the content script of my Chrome extension. I've read through the Match Patterns documentation, however I cannot find how to match the following scenarios:

http://mypage.com/some/sub/path - should match
http://mypage.com/some/sub/     - should not match

where as path can be anything.. I tried with the pattern

http://mypage.com/some/sub/*

but this also seems to cover http://mypage.com/some/sub/

Is there any way to use regular expressions for pattern matching? The rule should be: Match any url that starts with http://mypage.com/some/sub/ followed by atleast a single character

Solution is "exclude_matches" as described here .

"content_scripts": [
  {
    "matches": ["http://mypage.com/some/sub/*"],
    "exclude_matches": ["http://mypage.com/some/sub/"],
    "js": ["myscript.js"]
  }
],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM