Closed mika-cn closed 9 months ago
runtime.getBrowserInfo() is the right API to get the browser details e.g.
browser.runtime.getBrowserInfo().then(console.log);
// { name: "Firefox", vendor: "Mozilla", version: "124.0a1", buildID: "20240213210653" }
Unfortunately, the API is not supported on Chrome. I can workout a hacky way to detect but that is not 100% reliable. Let me see if there is any other option.
See also: Ability to detect browser variant / fork
PS. The repository for v8+ is https://github.com/foxyproxy/browser-extension
I have updated the browser detection for v8.10
Users that want to prevent fingerprint trackers may spoof their userAgent String to another total different type of browser (Chrome for example).
In version 8.9 of FoxyProxy, the file
content/app.js
use following code to detect browser type.Here,
navigator.userAgent
may not contains'Firefox'
even the browser IS Firefox. So other code that depends onApp.firefox
may not work as expected.In my test, The following code throw an error.
Here,
this.setChrome(pref)
get executed and throw an error about incognito staff. All defined patterns are not working, web requests were sent like there's not proxy at all.The browser type can be known when packing the extension. So we don't need to rely on
navigator.userAgent
here, as for detecting the OS, maybe we could use this API.For debugging, you can change the userAgent of Firefox by enter
about:config
page. And add an item calledgeneral.useragent.override
, Here's one value that i copy from the webMozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3690.90 Safari/537.36
.BTW, thank you for this amazing addon :)