Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.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
manifest.json上有多个匹配项_Json_Google Chrome_Google Chrome Extension - Fatal编程技术网

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中进行了更改,则必须重新加载以消除更改。