How to specify which content scripts which will ru

2019-02-27 18:02发布

When specifying parameters in the manifest file of a chrome extension there is an option all_frames. This allows the content scripts to be embedded in all frames of a page or not.

An example of what I want to achieve is have a.js running with all_frames=false and b.js with all_frames=true.

1条回答
男人必须洒脱
2楼-- · 2019-02-27 18:19

The content_scripts manifest property is an array, so you can define multiple content script specification objects:

"content_scripts": [
    {
      "matches": ["http://www.google.com/*"],
      "css": ["mystyles.css"],
      "js": ["a.js"],
      "all_frames": false
    },

    {
      "matches": ["http://www.yahoo.com/*"],
      "js": ["b.js"],
      "all_frames": true
    }
],
查看更多
登录 后发表回答