在谷歌浏览器中为不同的网站设置内容脚本 [英] Setting up content scripts for different sites in google-chrome

查看:132
本文介绍了在谷歌浏览器中为不同的网站设置内容脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了Google Chrome浏览器扩展程序实验室页面,但没有看到任何可以为不同网站使用不同内容脚本的示例。他们有一个页面显示如何在一个网站上有多个内容脚本,但不是相反的。有什么办法可以为不同的网站提供不同的内容脚本吗?

$ bname:我的扩展,
...
content_scripts:[
{
matches:[http://www.google。 com / *],
js:[script1.js]
},{
matches:[http://www.yahoo.com/* ],
js:[script2.js]
}
],
...
}


I looked at the google-chrome-extension labs page and I don't see any example where you can use different content scripts for different sites. They have a page showing how to have multiple content scripts on one site, but not the reverse. Is there any way to have different content scripts for different sites?

解决方案

{
  "name": "My extension",
  ...
  "content_scripts": [
    {
      "matches": ["http://www.google.com/*"],
      "js": ["script1.js"]
    },{
      "matches": ["http://www.yahoo.com/*"],
      "js": ["script2.js"]
    }
  ],
  ...
}

这篇关于在谷歌浏览器中为不同的网站设置内容脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆