Browser detection inside a WebExtension
Just for the record, if you really need to know about the browser container of your WebExtension, do NOT rely on StackOverflow answers... Most of them are based, directly or not, on the User Agent string. So spoofable, so unreliable. Some will recommend to rely on a given API, implemented by Firefox and not Edge, or Chrome and not the others. In general valid for a limited time only... You can't even rely on
msBrowser since there are polyfills for that to make WebExtensions cross-browser.
So the best and cleanest way is probably to rely on
chrome.extension.getURL("/") . It can start with "
chrome" or "
ms-browser". Unlikely to change in the near future. Simple to code, works in both content and background.