Chrome扩展程序 - 不区分大小写的内容脚本匹配

use*_*515 8 google-chrome-extension

在我的清单中,我正在根据特定的页面名称注入一些内容脚本.

但是,匹配似乎区分大小写,因此它匹配example.html但不匹配Example.html.

如何使其不区分大小写?

 "content_scripts": [
    {
      "matches": ["http://*/example.html"],
      "css": ["mystyles.css"],
      "js": ["jquery.js", "myscript.js"]
    }
  ]
Run Code Online (Sandbox Code Playgroud)

gka*_*pak 5

你可能已经想到了,但是没有办法不区分大小写地应用匹配模式.根据文档,匹配模式不支持正则表达式(仅限globs,即使用通配符进行模式匹配).

所以,你需要明确地输入不同的变化(例如http://*/example.htmlhttp://*/Example.html)

或者,您可以使用该include_globs元素,例如允许所有路径以任何字母开头,后跟"xample",但这也会允许.../Axample.html等路径,因此它可能不适合您的目的.

{
    "matches": ["http://*/*.html"],
    "include_globs": ["http://*/?xample.html"]
    ...
Run Code Online (Sandbox Code Playgroud)

另请参阅有关Match Patterns和globs的文档