12

我正在制作一个对谷歌结果网页执行某些操作的内容脚本。

下面的行manifest.json无效。

“匹配”:[“https://www.google.*/*”]

由于 manifest.json 中的上述行导致的错误是:

'content_scripts[0].matches[0]' 的值无效:主机通配符无效。

我想在 google.com、google.co.in、google.de 等各种域上运行脚本。我该如何实现?

4

1 回答 1

20

匹配模式的 TLD 中不允许使用通配符。

谷歌已经发布了支持的域列表。每个域都放在单独的一行上,看起来像.google.com. 您可以使用此列表生成有效的匹配模式,例如(例如,我已将其用作www子域):

"matches": [
    "http://www.google.com/*", "https://www.google.com/*",
    "http://www.google.ad/*", "https://www.google.ad/*",
    "http://www.google.ae/*", "https://www.google.ae/*",
    "http://www.google.com.af/*", "https://www.google.com.af/*",
    "http://www.google.com.ag/*", "https://www.google.com.ag/*",
    "http://www.google.com.ai/*", "https://www.google.com.ai/*",
    "http://www.google.am/*", "https://www.google.am/*",
    "http://www.google.co.ao/*", "https://www.google.co.ao/*",
    "http://www.google.com.ar/*", "https://www.google.com.ar/*",
    "http://www.google.as/*", "https://www.google.as/*",
    "http://www.google.at/*", "https://www.google.at/*",
    "http://www.google.com.au/*", "https://www.google.com.au/*",
    "http://www.google.az/*", "https://www.google.az/*",
    "http://www.google.ba/*", "https://www.google.ba/*",
    "http://www.google.com.bd/*", "https://www.google.com.bd/*",
    "http://www.google.be/*", "https://www.google.be/*",
    "http://www.google.bf/*", "https://www.google.bf/*",
    "http://www.google.bg/*", "https://www.google.bg/*",
    "http://www.google.com.bh/*", "https://www.google.com.bh/*",
    "http://www.google.bi/*", "https://www.google.bi/*",
    "http://www.google.bj/*", "https://www.google.bj/*",
    "http://www.google.com.bn/*", "https://www.google.com.bn/*",
    "http://www.google.com.bo/*", "https://www.google.com.bo/*",
    "http://www.google.com.br/*", "https://www.google.com.br/*",
    "http://www.google.bs/*", "https://www.google.bs/*",
    "http://www.google.co.bw/*", "https://www.google.co.bw/*",
    "http://www.google.by/*", "https://www.google.by/*",
    "http://www.google.com.bz/*", "https://www.google.com.bz/*",
    "http://www.google.ca/*", "https://www.google.ca/*",
    "http://www.google.cd/*", "https://www.google.cd/*",
    "http://www.google.cf/*", "https://www.google.cf/*",
    "http://www.google.cg/*", "https://www.google.cg/*",
    "http://www.google.ch/*", "https://www.google.ch/*",
    "http://www.google.ci/*", "https://www.google.ci/*",
    "http://www.google.co.ck/*", "https://www.google.co.ck/*",
    "http://www.google.cl/*", "https://www.google.cl/*",
    "http://www.google.cm/*", "https://www.google.cm/*",
    "http://www.google.cn/*", "https://www.google.cn/*",
    "http://www.google.com.co/*", "https://www.google.com.co/*",
    "http://www.google.co.cr/*", "https://www.google.co.cr/*",
    "http://www.google.com.cu/*", "https://www.google.com.cu/*",
    "http://www.google.cv/*", "https://www.google.cv/*",
    "http://www.google.com.cy/*", "https://www.google.com.cy/*",
    "http://www.google.cz/*", "https://www.google.cz/*",
    "http://www.google.de/*", "https://www.google.de/*",
    "http://www.google.dj/*", "https://www.google.dj/*",
    "http://www.google.dk/*", "https://www.google.dk/*",
    "http://www.google.dm/*", "https://www.google.dm/*",
    "http://www.google.com.do/*", "https://www.google.com.do/*",
    "http://www.google.dz/*", "https://www.google.dz/*",
    "http://www.google.com.ec/*", "https://www.google.com.ec/*",
    "http://www.google.ee/*", "https://www.google.ee/*",
    "http://www.google.com.eg/*", "https://www.google.com.eg/*",
    "http://www.google.es/*", "https://www.google.es/*",
    "http://www.google.com.et/*", "https://www.google.com.et/*",
    "http://www.google.fi/*", "https://www.google.fi/*",
    "http://www.google.com.fj/*", "https://www.google.com.fj/*",
    "http://www.google.fm/*", "https://www.google.fm/*",
    "http://www.google.fr/*", "https://www.google.fr/*",
    "http://www.google.ga/*", "https://www.google.ga/*",
    "http://www.google.ge/*", "https://www.google.ge/*",
    "http://www.google.gg/*", "https://www.google.gg/*",
    "http://www.google.com.gh/*", "https://www.google.com.gh/*",
    "http://www.google.com.gi/*", "https://www.google.com.gi/*",
    "http://www.google.gl/*", "https://www.google.gl/*",
    "http://www.google.gm/*", "https://www.google.gm/*",
    "http://www.google.gp/*", "https://www.google.gp/*",
    "http://www.google.gr/*", "https://www.google.gr/*",
    "http://www.google.com.gt/*", "https://www.google.com.gt/*",
    "http://www.google.gy/*", "https://www.google.gy/*",
    "http://www.google.com.hk/*", "https://www.google.com.hk/*",
    "http://www.google.hn/*", "https://www.google.hn/*",
    "http://www.google.hr/*", "https://www.google.hr/*",
    "http://www.google.ht/*", "https://www.google.ht/*",
    "http://www.google.hu/*", "https://www.google.hu/*",
    "http://www.google.co.id/*", "https://www.google.co.id/*",
    "http://www.google.ie/*", "https://www.google.ie/*",
    "http://www.google.co.il/*", "https://www.google.co.il/*",
    "http://www.google.im/*", "https://www.google.im/*",
    "http://www.google.co.in/*", "https://www.google.co.in/*",
    "http://www.google.iq/*", "https://www.google.iq/*",
    "http://www.google.is/*", "https://www.google.is/*",
    "http://www.google.it/*", "https://www.google.it/*",
    "http://www.google.je/*", "https://www.google.je/*",
    "http://www.google.com.jm/*", "https://www.google.com.jm/*",
    "http://www.google.jo/*", "https://www.google.jo/*",
    "http://www.google.co.jp/*", "https://www.google.co.jp/*",
    "http://www.google.co.ke/*", "https://www.google.co.ke/*",
    "http://www.google.com.kh/*", "https://www.google.com.kh/*",
    "http://www.google.ki/*", "https://www.google.ki/*",
    "http://www.google.kg/*", "https://www.google.kg/*",
    "http://www.google.co.kr/*", "https://www.google.co.kr/*",
    "http://www.google.com.kw/*", "https://www.google.com.kw/*",
    "http://www.google.kz/*", "https://www.google.kz/*",
    "http://www.google.la/*", "https://www.google.la/*",
    "http://www.google.com.lb/*", "https://www.google.com.lb/*",
    "http://www.google.li/*", "https://www.google.li/*",
    "http://www.google.lk/*", "https://www.google.lk/*",
    "http://www.google.co.ls/*", "https://www.google.co.ls/*",
    "http://www.google.lt/*", "https://www.google.lt/*",
    "http://www.google.lu/*", "https://www.google.lu/*",
    "http://www.google.lv/*", "https://www.google.lv/*",
    "http://www.google.com.ly/*", "https://www.google.com.ly/*",
    "http://www.google.co.ma/*", "https://www.google.co.ma/*",
    "http://www.google.md/*", "https://www.google.md/*",
    "http://www.google.me/*", "https://www.google.me/*",
    "http://www.google.mg/*", "https://www.google.mg/*",
    "http://www.google.mk/*", "https://www.google.mk/*",
    "http://www.google.ml/*", "https://www.google.ml/*",
    "http://www.google.mn/*", "https://www.google.mn/*",
    "http://www.google.ms/*", "https://www.google.ms/*",
    "http://www.google.com.mt/*", "https://www.google.com.mt/*",
    "http://www.google.mu/*", "https://www.google.mu/*",
    "http://www.google.mv/*", "https://www.google.mv/*",
    "http://www.google.mw/*", "https://www.google.mw/*",
    "http://www.google.com.mx/*", "https://www.google.com.mx/*",
    "http://www.google.com.my/*", "https://www.google.com.my/*",
    "http://www.google.co.mz/*", "https://www.google.co.mz/*",
    "http://www.google.com.na/*", "https://www.google.com.na/*",
    "http://www.google.com.nf/*", "https://www.google.com.nf/*",
    "http://www.google.com.ng/*", "https://www.google.com.ng/*",
    "http://www.google.com.ni/*", "https://www.google.com.ni/*",
    "http://www.google.ne/*", "https://www.google.ne/*",
    "http://www.google.nl/*", "https://www.google.nl/*",
    "http://www.google.no/*", "https://www.google.no/*",
    "http://www.google.com.np/*", "https://www.google.com.np/*",
    "http://www.google.nr/*", "https://www.google.nr/*",
    "http://www.google.nu/*", "https://www.google.nu/*",
    "http://www.google.co.nz/*", "https://www.google.co.nz/*",
    "http://www.google.com.om/*", "https://www.google.com.om/*",
    "http://www.google.com.pa/*", "https://www.google.com.pa/*",
    "http://www.google.com.pe/*", "https://www.google.com.pe/*",
    "http://www.google.com.ph/*", "https://www.google.com.ph/*",
    "http://www.google.com.pk/*", "https://www.google.com.pk/*",
    "http://www.google.pl/*", "https://www.google.pl/*",
    "http://www.google.pn/*", "https://www.google.pn/*",
    "http://www.google.com.pr/*", "https://www.google.com.pr/*",
    "http://www.google.ps/*", "https://www.google.ps/*",
    "http://www.google.pt/*", "https://www.google.pt/*",
    "http://www.google.com.py/*", "https://www.google.com.py/*",
    "http://www.google.com.qa/*", "https://www.google.com.qa/*",
    "http://www.google.ro/*", "https://www.google.ro/*",
    "http://www.google.ru/*", "https://www.google.ru/*",
    "http://www.google.rw/*", "https://www.google.rw/*",
    "http://www.google.com.sa/*", "https://www.google.com.sa/*",
    "http://www.google.com.sb/*", "https://www.google.com.sb/*",
    "http://www.google.sc/*", "https://www.google.sc/*",
    "http://www.google.se/*", "https://www.google.se/*",
    "http://www.google.com.sg/*", "https://www.google.com.sg/*",
    "http://www.google.sh/*", "https://www.google.sh/*",
    "http://www.google.si/*", "https://www.google.si/*",
    "http://www.google.sk/*", "https://www.google.sk/*",
    "http://www.google.com.sl/*", "https://www.google.com.sl/*",
    "http://www.google.sn/*", "https://www.google.sn/*",
    "http://www.google.so/*", "https://www.google.so/*",
    "http://www.google.sm/*", "https://www.google.sm/*",
    "http://www.google.st/*", "https://www.google.st/*",
    "http://www.google.com.sv/*", "https://www.google.com.sv/*",
    "http://www.google.td/*", "https://www.google.td/*",
    "http://www.google.tg/*", "https://www.google.tg/*",
    "http://www.google.co.th/*", "https://www.google.co.th/*",
    "http://www.google.com.tj/*", "https://www.google.com.tj/*",
    "http://www.google.tk/*", "https://www.google.tk/*",
    "http://www.google.tl/*", "https://www.google.tl/*",
    "http://www.google.tm/*", "https://www.google.tm/*",
    "http://www.google.tn/*", "https://www.google.tn/*",
    "http://www.google.to/*", "https://www.google.to/*",
    "http://www.google.com.tr/*", "https://www.google.com.tr/*",
    "http://www.google.tt/*", "https://www.google.tt/*",
    "http://www.google.com.tw/*", "https://www.google.com.tw/*",
    "http://www.google.co.tz/*", "https://www.google.co.tz/*",
    "http://www.google.com.ua/*", "https://www.google.com.ua/*",
    "http://www.google.co.ug/*", "https://www.google.co.ug/*",
    "http://www.google.co.uk/*", "https://www.google.co.uk/*",
    "http://www.google.com.uy/*", "https://www.google.com.uy/*",
    "http://www.google.co.uz/*", "https://www.google.co.uz/*",
    "http://www.google.com.vc/*", "https://www.google.com.vc/*",
    "http://www.google.co.ve/*", "https://www.google.co.ve/*",
    "http://www.google.vg/*", "https://www.google.vg/*",
    "http://www.google.co.vi/*", "https://www.google.co.vi/*",
    "http://www.google.com.vn/*", "https://www.google.com.vn/*",
    "http://www.google.vu/*", "https://www.google.vu/*",
    "http://www.google.ws/*", "https://www.google.ws/*",
    "http://www.google.rs/*", "https://www.google.rs/*",
    "http://www.google.co.za/*", "https://www.google.co.za/*",
    "http://www.google.co.zm/*", "https://www.google.co.zm/*",
    "http://www.google.co.zw/*", "https://www.google.co.zw/*",
    "http://www.google.cat/*", "https://www.google.cat/*"
]

可以使用http://andhttps://来代替。*://请注意,存在更多搜索门户:

于 2012-06-17T08:21:03.523 回答