匹配Chrome扩展程序中除某些网址之外的所有网址

Rya*_*ush 4 regex google-chrome-extension

我试图让它以便我的内容脚本在除了3之外的每个站点上运行.我知道可能有一种方法可以用正则表达式来完成它但我不想这样做.chrome扩展清单是否允许例外?

如果正则表达式是唯一的解决方案,并且任何人都知道排除这3个URL的模式也会很棒.

https://www.linkedin.com/
https://mail.google.com/
https://twitter.com/
Run Code Online (Sandbox Code Playgroud)

Tee*_*emm 9

https://developer.chrome.com/extensions/content_scripts列出了一个选项exclude_matches:

"content_scripts": [
    {
        "matches": ["<all_urls>"],
        "js": ["myscript.js"],
        "exclude_matches": [
            "https://www.linkedin.com/",
            "https://mail.google.com/",
            "https://twitter.com/"
        ]
    }
]
Run Code Online (Sandbox Code Playgroud)

我猜你最后会想要一个*:"https://twitter.com/*"等等,在这些域的所有页面上排除脚本,而不仅仅是主页.您也可以查看该exclude_globs选项.