如何使chrome扩展程序在特定站点的所有域区域上工作?

时间:2019-03-14 12:54:48

标签: google-chrome-extension

我有一个很小的chrome扩展程序,可在Google翻译 com 上使用 如何使它在所有域区域(不仅是.com)上都能正常工作?

尝试以下操作,但似乎不起作用。 "matches": [ "*://translate.google.*/*" ],

Error
Invalid value for 'content_scripts[0].matches[0]': Invalid host wildcard.

这不是Chrome extension: Run on all google domains and a specific page的副本 我希望它仅在翻译页面上起作用。

  "matches": [ "*://*/*" ],
  "include_globs": [
    "*://translate.google.*/*"
  ]

这部分使其可以在google.com搜索页面上使用。 我不需要这个。

1 个答案:

答案 0 :(得分:1)

感谢@wOxxOm

  1. 转到http://www.google.com/supported_domains
  2. 打开控制台并粘贴以下内容:
copy(document.body.innerText.split(" ").map((item) => { return `*://translate${item}/*` }))
  1. 转到清单文件,并将matches": []数组替换为刚复制的内容。
相关问题