扩展影响另一个网页

Extension affects another web page

我在创建 Chrome 扩展时遇到了一些问题。该代码影响Chrome中打开的所有页面,我该如何解决?

我的manifest.json:

{
    "manifest_version": 2,
    "name": "Merch Tools 41studio",
    "description": "report app",
    "version": "1.0",
    "background": {
        "scripts": ["assets/js/jquery.min.js", "assets/js/background.js"]
    },
    "browser_action": {
        "default_icon": "assets/image/icon.png",
        "default_popup": "popup.html"
    },
    "permissions": ["tabs"],
    "content_scripts": [{
        "matches": ["http://*/*", "https://*/*"],
        "js": ["assets/js/jquery.min.js", "assets/js/highcharts.js"]
    }]
}

您需要通过更改 content_scripts 中的 matches 属性 来限制内容脚本 运行 所在的域列表。具有 "http://*/*","https://*/*" 表示所有 http 和 https 网站上的内容脚本 运行s。相反,您可以指定要扩展到 运行 的网站列表。

{
  "manifest_version": 2,
  "name": "Merch Tools 41studio",
  "description": "report app",
  "version": "1.0",
  "background": {
    "scripts": ["assets/js/jquery.min.js", "assets/js/background.js"]
  },
  "browser_action": {
    "default_icon": "assets/image/icon.png",
    "default_popup": "popup.html"
  },
  "permissions": ["tabs"],
  "content_scripts": [{
    "matches": ["http:/yoursite.com/*"], // Change this to the sites you want your extension to run on
    "js": ["assets/js/jquery.min.js", "assets/js/highcharts.js"]
  }]
}