manifest.json上有多个匹配项
我想在manifest.json上有多个匹配项,json,google-chrome,google-chrome-extension,Json,Google Chrome,Google Chrome Extension,我想在google.com和twitch.tv上匹配我的chrome扩展运行。我尝试了以下两种方法: 第一种方式: "content_scripts": [ { "exclude_globs": [ ], "include_globs": [ "*" ], "js":["jquery.user.js","h.js", "main.js"], "matches": ["*//google.com", "*//twitc
google.com
和twitch.tv上匹配我的chrome扩展运行。
我尝试了以下两种方法:
第一种方式:
"content_scripts": [ {
"exclude_globs": [ ],
"include_globs": [ "*" ],
"js":["jquery.user.js","h.js", "main.js"],
"matches": ["*//google.com", "*//twitch.tv/"],
"run_at": "document_end",
"permissions":["tabs","<all_urls>"]
} ],
"content_scripts": [ {
"exclude_globs": [ ],
"include_globs": [ "*" ],
"js":["jquery.user.js","h.js", "main.js"],
"matches": ["*//google.com, *//twitch.tv/"],
"run_at": "document_end",
"permissions":["tabs","<all_urls>"]
} ],
“内容脚本”:[{
“排除全球”:[],
“包括全球”:[“*”],
“js”:[“jquery.user.js”、“h.js”、“main.js”],
“匹配项”:[“*//google.com”,“*//twitch.tv/”],
“运行时间”:“文件结束时间”,
“权限”:[“选项卡”,“”]
} ],
第二种方式:
"content_scripts": [ {
"exclude_globs": [ ],
"include_globs": [ "*" ],
"js":["jquery.user.js","h.js", "main.js"],
"matches": ["*//google.com", "*//twitch.tv/"],
"run_at": "document_end",
"permissions":["tabs","<all_urls>"]
} ],
"content_scripts": [ {
"exclude_globs": [ ],
"include_globs": [ "*" ],
"js":["jquery.user.js","h.js", "main.js"],
"matches": ["*//google.com, *//twitch.tv/"],
"run_at": "document_end",
"permissions":["tabs","<all_urls>"]
} ],
“内容脚本”:[{
“排除全球”:[],
“包括全球”:[“*”],
“js”:[“jquery.user.js”、“h.js”、“main.js”],
“匹配项”:[“*//google.com,*//twitch.tv/”],
“运行时间”:“文件结束时间”,
“权限”:[“选项卡”,“”]
} ],
我用引号将两者分开的方式崩溃了,不起作用,我没有将URL的
分开的方式只运行了第一个URL
(谷歌)
那么有没有办法让它在两个URL上运行呢
谢谢
如果您需要为这两个域加载conman js和css
“内容脚本”:[
{
“匹配项”:[“”,“”],
“css”:,
“js”:
“run_at”:“document_end”//如果您想在文档准备好后加载js和css,请添加此标记
}
],
如果您需要为每个域加载单独的css和js
“内容脚本”:[
{
“匹配项”:[“”],
“css”:,
“js”:
“run_at”:“document_end”//如果您想在文档准备好后加载js和css,请添加此标记
},
{
“匹配项”:[“”],
“css”:,
“js”:
“run_at”:“document_end”//如果您想在文档准备好后加载js和css,请添加此标记
}
]
权限
超出了内容\u脚本
。twitch.tv
的匹配模式有一个额外的斜杠。试试*/*.twitch.tv
manifest.json
"content_scripts": [ {
"js":["jquery.user.js","h.js", "main.js"],
"matches": ["*//*.google.com", "*//*.twitch.tv"],
"run_at": "document_end",
} ],
"permissions":["tabs","<all_urls>"]
“内容脚本”:[{
“js”:[“jquery.user.js”、“h.js”、“main.js”],
“匹配项”:[“*/*.google.com”、“*/*.twitch.tv”],
“运行时间”:“文件结束时间”,
} ],
“权限”:[“选项卡”,“”]
如果您通读了我的问题,我已经尝试了您的第一种方法,但没有成功。仅供参考:-如果您在manifest.JSon中进行了更改,则必须重新加载以消除更改。