Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Extension - case insensitive content script matches

In my manifest I am injecting some content scripts based on a specific page name.

However it appears that the matching is case sensitive, so it matches example.html but not Example.html.

How can I make it not case sensitive?

 "content_scripts": [
    {
      "matches": ["http://*/example.html"],
      "css": ["mystyles.css"],
      "js": ["jquery.js", "myscript.js"]
    }
  ]
like image 951
user887515 Avatar asked Jun 07 '13 21:06

user887515


1 Answers

You have probably figured that out by now, but there is no way to apply a match pattern case-insensitively. According to the docs, the Match Patterns do not support regular expressions (only globs, a.k.a. pattern matching using wildcard characters).

So, you need to explicitely enter the different variation (e.g. http://*/example.html and http://*/Example.html)

Alternatively, you could use the include_globs element, e.g. allowing all paths starting with any letter followed by "xample", but this will also allow paths like .../Axample.html etc, so it might probably not fit your purpose.

{
    "matches": ["http://*/*.html"],
    "include_globs": ["http://*/?xample.html"]
    ...

See, also, the documentation about Match Patterns and globs

like image 153
gkalpak Avatar answered Nov 02 '22 12:11

gkalpak