Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy by patterns not working if firefox users change their userAgent to another platform #220

Closed
mika-cn opened this issue Feb 14, 2024 · 2 comments

Comments

@mika-cn
Copy link

mika-cn commented Feb 14, 2024

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.

// content/app.js
export class App {

  static firefox = navigator.userAgent.includes('Firefox');
  static android = navigator.userAgent.includes('Android');
  ...
}

Here, navigator.userAgent may not contains 'Firefox' even the browser IS Firefox. So other code that depends on App.firefox may not work as expected.

In my test, The following code throw an error.

// content/proxy.js
  static async set(pref) {
    ...
    App.firefox ? this.setFirefox(pref, conf) : this.setChrome(pref);
    ...
  }

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 called general.useragent.override, Here's one value that i copy from the web Mozilla/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 :)

@erosman
Copy link
Collaborator

erosman commented Feb 14, 2024

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

@erosman
Copy link
Collaborator

erosman commented Feb 14, 2024

I have updated the browser detection for v8.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants