Limit Chrome Extension to certain URLs?

前端 未结 3 1176
失恋的感觉
失恋的感觉 2020-12-31 02:41

Is there a way to limit a Chrome extension to only run on certain urls?

Say I want the extension to run only if the domain is Amazon.com. I realize you can put a che

相关标签:
3条回答
  • 2020-12-31 02:45

    As a user, with Chrome 71 (or maybe even before) with chrome://flags/#extension-active-script-permission (you may need to enable User consent for extension scripts flag) allows you to right click extension icons and select "This can read and change site data" then you can choose:

    • When you click the extension
    • On current-domain-name.com
    • On all sites (default)

    This way you can limit an extension to only run on certain domains very quickly.

    0 讨论(0)
  • 2020-12-31 02:45

    There's a Chrome extension for this: Extension Automation. I had gone the route of modifying manifests before, but this is easier.

    0 讨论(0)
  • 2020-12-31 03:09

    Welp, it figures I would find the answer to this right after posting the question, even though I have been stuck for a while...

    http://code.google.com/chrome/extensions/content_scripts.html

    In manifest.json:

    "content_scripts": [
        {
          "matches": [...urls...],
          "exclude_matches": [...urls...],
          "css": [...]
        }
    ]
    
    0 讨论(0)
提交回复
热议问题