【问题标题】:How to specify which content scripts which will run on all_frames and which won't?如何指定哪些内容脚本将在 all_frames 上运行,哪些不会?
【发布时间】:2013-04-05 14:24:32
【问题描述】:

在 chrome 扩展的清单文件中指定参数时,有一个选项 all_frames。这允许内容脚本嵌入或不嵌入页面的所有框架中。

我想要实现的一个示例是使用 all_frames=false 运行 a.js,使用 all_frames=true 运行 b.js。

【问题讨论】:

    标签: javascript iframe google-chrome-extension manifest frames


    【解决方案1】:

    content_scripts 清单属性是一个数组,因此您可以定义多个内容脚本规范对象:

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

    【讨论】:

    • 非常感谢您的快速回复,我从一开始就没有注意到这似乎有点愚蠢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    • 2012-10-19
    • 1970-01-01
    相关资源
    最近更新 更多