Chrome 如何在所有Google(国际)页面上加载内容脚本?

holgip5t  于 2023-08-01  发布在  Go
关注(0)|答案(1)|浏览(117)

对于Google-Chrome扩展程序,我想在所有Google页面上加载内容脚本。最好的方法是什么?
我在manifest.json中尝试了这个,但它不起作用:

"matches": ["http://www.google.*/*", "https://www.google.*/*"],

字符串
这“工作”,但它是一个有点长的写,我不认为这是最好的做法:

"matches": ["http://www.google.com/*", "https://www.google.com/*", "http://www.google.fr/*", "https://www.google.fr/*", "http://www.google.de/*", "https://www.google.de/*", etc..."],

uajslkp6

uajslkp61#

请参见 * 匹配模式和全局对象 *。不幸的是,Google-Chrome在其matches规范中没有一个很好的顶级域(TLD)机制。因此,http://www.google.*/*抛出错误,并且不支持http://www.google.tld/*Greasemonkey syntax)。
要解决此问题,请加宽matches参数并使用include_globs参数过滤结果。
像这样:

"matches":        ["http://*/*", "https://*/*"],
"include_globs":  ["http://www.google.*/*", "https://www.google.*/*"],

字符串

相关问题