Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Chrome扩展,使内容脚本在所有页面上运行?_Javascript_Json_Google Chrome Extension - Fatal编程技术网

Javascript Chrome扩展,使内容脚本在所有页面上运行?

Javascript Chrome扩展,使内容脚本在所有页面上运行?,javascript,json,google-chrome-extension,Javascript,Json,Google Chrome Extension,我想要一个chrome扩展,它可以将每个网站的高亮颜色改为红色,我对CSS方面很在行,尽管我不知道如何使它在所有页面上都能工作。这是我当前的代码: { "manifest_version": 2, "name": "CustomizeMore", "version": "0.1.0", "description": "Customize contents on a webpage!", "content_scripts": [{ "css": ["main.css

我想要一个chrome扩展,它可以将每个网站的高亮颜色改为红色,我对CSS方面很在行,尽管我不知道如何使它在所有页面上都能工作。这是我当前的代码:

{
  "manifest_version": 2,

  "name": "CustomizeMore",
  "version": "0.1.0",
  "description": "Customize contents on a webpage!",

  "content_scripts": [{
    "css": ["main.css"],
    "js": ["main.js"],
    "matches": ["http://*/*"]
   }]


}
目前,它运行在使用HTTP的站点上,但不在使用HTTPS的站点上。如何使其在使用HTTP或HTTPS的站点上运行?

您的错误在matches定义中,您只将其定义为匹配以HTTP://schema开头的页面

如果您只想专门针对http://和https://-prefixed 页面,只需将定义添加到matches参数:

{
  "manifest_version": 2,

  "name": "CustomizeMore",
  "version": "0.1.0",
  "description": "Customize contents on a webpage!",

  "content_scripts": [{
    "css": ["main.css"],
    "js": ["main.js"],
    "matches": ["http://*/*", "https://*/*"]
   }]


}
或者,您可以通过将matches参数更改为string documentation页面来匹配每个前缀,而不仅仅是http://或https://前缀

{
  "manifest_version": 2,

  "name": "CustomizeMore",
  "version": "0.1.0",
  "description": "Customize contents on a webpage!",

  "content_scripts": [{
    "css": ["main.css"],
    "js": ["main.js"],
    "matches": ["<all_urls>"]
   }]


}