Javascript Chrome扩展,使内容脚本在所有页面上运行?
我想要一个chrome扩展,它可以将每个网站的高亮颜色改为红色,我对CSS方面很在行,尽管我不知道如何使它在所有页面上都能工作。这是我当前的代码: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
{
"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>"]
}]
}