在subtest中验证浏览器类型。

发布于 2025-01-28 23:07:34 字数 1009 浏览 2 评论 0原文

我正在尝试创建一个跨浏览器扩展名,并且遇到了一个小打ic。

  1. 清单_version:3不支持Firefox上(尽管我可以使用清单V2,v2在Chrome上正常工作,但弹出了警告,该警告将在2023年折旧)。

    >

  2. “ browser_specific_settings”键仅在firefox上起作用并在chrome中抛出错误,因为这是特定于gecko的。

有什么方法可以验证浏览器类型?也许这样的东西:

{   
    "if": { "browser_type": chrome },
    "then": { "manifest_version": 3 },
    "else": {
        "if": { "browser_type": firefox },
        "then": { "manifest_version": 2,
            "browser_specific_settings": {
                "gecko": {
                    "id": "[email protected]"
                }
            } 
        }
    },
    "name": "Custom Addon",
    "version": "0.1",

    "description": "Addon Test",
    
    "incognito": "spanning",
    "permissions": ["tabs"],
    "chrome_url_overrides": {
     "newtab": "test.html"
    }
}

I am trying to create a cross-browser extension and I have run into a small hiccup.

  1. manifest_version: 3 isn't supported on firefox (albeit I could used manifest v2 which works fine on chrome but pops up with a warning that it will be depreciated in 2023).

  2. The "browser_specific_settings" key only works on firefox and throws up an error in chrome as this is gecko specific.

Is there any way I can validate for the browser type? Maybe something like this:

{   
    "if": { "browser_type": chrome },
    "then": { "manifest_version": 3 },
    "else": {
        "if": { "browser_type": firefox },
        "then": { "manifest_version": 2,
            "browser_specific_settings": {
                "gecko": {
                    "id": "[email protected]"
                }
            } 
        }
    },
    "name": "Custom Addon",
    "version": "0.1",

    "description": "Addon Test",
    
    "incognito": "spanning",
    "permissions": ["tabs"],
    "chrome_url_overrides": {
     "newtab": "test.html"
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文