Chrome extension - case-insensitive content script matches

In my manifest, I embed some content scripts based on a specific page name.

However, the match seems to be case sensitive, so it matches example.html, but not Example.html.

How can I make this case insensitive?

"content_scripts": [ { "matches": ["http://*/example.html"], "css": ["mystyles.css"], "js": ["jquery.js", "myscript.js"] } ] 
+6
source share
1 answer

You probably guessed it, but there is a way not to use a case-insensitive match pattern. According to docs, matching patterns do not support regular expressions ( globs only, similar to wildcard patterns).

So, you need to explicitly enter various options (e.g. http://*/example.html and http://*/example.html )

Alternatively, you can use the include_globs element, for example. resolving all paths starting with any letter followed by "xample", but it also allows paths such as .../Axample.html , etc., so maybe this doesn't suit your purpose.

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

See also documentation on Match Patterns and globs.

+4
source

Source: https://habr.com/ru/post/946821/


All Articles