'Validating browser type in manifest.json for a cross browser addon

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"
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source