Chrome extension: Run on all google domains and a specific page

后端 未结 1 474
再見小時候
再見小時候 2020-12-06 03:43

I want my content script to match all google domains, and a specific page. I know this is not possible.

Manifest.json

\"content_scripts\": [{
                


        
1条回答
  •  难免孤独
    2020-12-06 04:28

    Listing all Google domains is not that difficult, because Google has published a list of all public Google domains at http://www.google.com/supported_domains. Prefix every item in this list with "*://* and add the ", suffix to every item. Then copy-paste the result to your manifest file.

    An alternative option is to use the "include_globs" field (this is applied after "matches"):

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

    (I've replaced "*://www.google.com/*" with "*://*.google.com/*, because of subdomains like https://encrypted.google.com/)

    0 讨论(0)
提交回复
热议问题