How to specify which content scripts which will run on all_frames and which won't?

我的未来我决定 提交于 2019-12-20 04:51:38

问题


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:


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
    }
],


来源:https://stackoverflow.com/questions/15836420/how-to-specify-which-content-scripts-which-will-run-on-all-frames-and-which-won

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!