Chrome content scripts
I don't know if anyone has some insight with the json chrome uses for the manifest.json file... but essentially whenever I put a '?' in a url in the "matches", nothing is ever matched.
For example:
"content_script开发者_StackOverflow社区s": [ {
"css" : [ "mod/reformat.css" ],
"matches": [ "http://www.google.com/search*" ]
} ],
will inject reformat.css into google's search page just fine.
but when I try and make it more specific,
"content_scripts": [ {
"css" : [ "mod/reformat.css" ],
"matches": [ "http://www.google.com/search?*" ]
} ],
nothing is matched, even when the url does in fact match that pattern fine.
Would anyone have any potential insight on how the match pattern string is used inside chrome and how you would perform some more complex matching? I feel maybe the '?' is acting as a special char for pattern matching, and maybe there's a way to encode or... idk.
The official document talking about match pattern i can find is this one and this one.
I copied the content which is useful to here.
Glob properties follow a different, more flexible syntax than match patterns. Acceptable glob strings are URLs that may contain "wildcard" asterisks and question marks.
The asterisk (*) matches any string of any length (including the empty string); the question mark (?) matches any single character.
For example, the glob "http://???.example.com/foo/*" matches any of the following:
"http://www.example.com/foo/bar" "http://the.example.com/foo/"
In your case search?
will match searcha
,searchb
but no match search
精彩评论