Skip to content

fix: add mobile to user-agent

Adds Mobile to the platforms section of the User-Agent.

This solution allows us to make the change we want, but also avoid maintaining the version numbers. It also future-proofs the config by taking the existing values where it can instead of hard-coding new ones, such as the CPU architecture.

Tests

  • Slacks webapp no longer works. It seems they block all Mobile devices from accessing it. Now it just wants me to install the Linux app which doesn't support aarch64. This requires overriding the User-Agent via an extension like before. [reference]
  • addons.mozilla.org still works and users can install add-ons.

This is partially undoing what I was hoping to achieve in !34 (merged). However, this is still a good change, since now websites will be able to identify a Linux on Mobile device, so it's easier to complain at them.

Notes

I put Mobile before rv, because in other Firefox mobile user-agents, this is where Mozilla puts it.

Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox#mobile_and_tablet_indicators

I set rv (Gecko version) and Firefox version to the same value, as this is what Firefox does for all modern versions. New releases should not have a different rv and Firefox version number.

In recent browsers, geckoversion is the same as firefoxversion.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox#general_form

I set Gecko to be the literal string 20100101 because that's what Mozilla does across all desktop builds. Mobile builds use the Firefox/Gecko version.

On Desktop, geckotrail is the fixed string "20100101"

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox#general_form

All version numbers are followed with .0 as this is what we see in the wild. Regardless of what the minor version is, the major is always appended with a minor version of 0 in the user-agent string and is never missing.

Firefox/firefoxversion indicates the browser is Firefox, and provides the version (such as "17.0").

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox#general_form

I use values from appinfo for other parts of the User-Agent, even though it's not necessary. I thought it made sense, so it would be easier to reuse or port the config for other Firefox-derived browsers, or other devices in general regardless of CPU architecture.


PinePhone Firefox ESR (Before/After)

Mozilla/5.0 (X11; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/115.0

Mozilla/5.0 (X11; Linux aarch64; Mobile; rv:115.0) Gecko/20100101 Firefox/115.0

Desktop Firefox ESR (Before/After)

Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0

Mozilla/5.0 (X11; Linux x86_64; Mobile; rv:102.0) Gecko/20100101 Firefox/102.0

I have no use-case for needing a config like this on desktop. It was just convenient to experiment on the config there, and so I wrote one that should work on both.

Open Questions

We could consider doing Gecko/${version}.0 instead to match Firefox mobile user-agents. Any feedback?

Related

Edited by Seth Falco

Merge request reports