【问题标题】:Content script matching top-level domains like all google.*与所有 google 等顶级域匹配的内容脚本。*
【发布时间】:2013-09-07 22:53:56
【问题描述】:

我希望我的内容脚本匹配所有 google 域和特定页面。我知道这是不可能的。

Manifest.json

"content_scripts": [{
        "matches": [
           ,"*://www.google.*"
           ,"*://www.youtube.com/*"
           ,"*://readthedocs.org/*"]
       ,
       ....

还有其他方法可以做到这一点吗?只是想在我列出 Google 拥有的所有域之前确保 :)

【问题讨论】:

    标签: google-chrome google-chrome-extension match content-script


    【解决方案1】:

    列出所有 Google 域并不难,因为 Google 已在 http://www.google.com/supported_domains 发布了所有公共 Google 域的列表。使用"*://* 为该列表中的每个项目添加前缀,并为每个项目添加", 后缀。然后将结果复制粘贴到您的清单文件中。

    另一种选择是使用"include_globs" 字段(在“匹配”之后应用):

    {
        ....
        "content_scripts": [{
            "matches": [ "*://*/*" ],
            "include_globs": [
                "*://*.google.*/*",
                "*://*.youtube.com/*",
                "*://readthedocs.org/*"
            ],
            "js": [ "contentscript.js" ]
        }]
    }
    

    (我已将 "*://www.google.com/*" 替换为 "*://*.google.com/*,因为像 https://encrypted.google.com/ 这样的子域)

    【讨论】:

    • 您链接的列表实际上是不完整的。它里面没有google.ng
    • @Olumide 很有趣。查找 Google 域的另一种方法是查看证书透明度日志,例如在crt.sh/?Identity=google.%25。此列表确实包括 google.ng。它还包括许多以 google.* 开头的非 Google 域,但您可以将我的答案中的列表与日志进行比较,查找丢失的条目并手动检查/验证未知条目。
    • 感谢您的链接。另一种验证方法是过滤掉那些不是 google crt.sh/?Identity=google.%25&iCAID=1348 颁发的证书
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-04
    • 2016-05-14
    • 1970-01-01
    相关资源
    最近更新 更多