Monday, April 8, 2013

Firefox: Change User Agent String For a Specific Domain

Updated 2014-04-28:
Reader G. pointed out that this feature is no longer supported. There was a regression found in branch 25 and it was marked as "won't fix" on 2013-11-01. :(
Bug 933959 - general.useragent.override.[domain] (about:config entry) stopped working


1. Enter about:config in the URL
2. Search for general.useragent.site_specific_overrides
3. Ensure its value is set to true
4. Right-click -> New -> String
5. Type general.useragent.override.[domain].com
     e.g. general.useragent.override.blogger.com
6. Enter the new user agent string


For example:
Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; Nexus One Build/ERE27) AppleWebkit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17


Extra:
* To check your current user agent, enter about: in the URL
* To revert your changes, right-click on general.useragent.override.[domain].com -> Reset. The key will go away when you refresh the page.

11 comments:

Anonymous said...

Do you know if this works on Firefox for android?

Eric said...

I tested Firefox for Android version 20.0.1, while general.useragent.site_specific_overrides present and default to true, I couldn't get the override to work for http://whatsmyuseragent.com/

However, the non-domain-specific override (general.useragent.override) is working as expected. Note that you need to un-check Settings -> Request Desktop Site

Anonymous said...

For site specific overrides to work on Firefox for Android, both general.useragent.site_specific_overrides and general.useragent.enable_overrides have to be set to true.

Eric said...

I tried setting both options to true but it still does not work.

Since non-domain-specific override is working without setting general.useragent.enable_overrides, I wonder why you said it is needed for domain-specific override to work. Is it being documented somewhere?

Anonymous said...

I was mislead by comments in the code concerning general.useragent.enable_overrides and the fact that I was not using the current version of firefox, sorry. general.useragent.site_specific_overrides + general.useragent.override.* support in Firefox for Android landed with bug 768035, which is targeted for Firefox 22, and therefore is currently present and works in Aurora and Nightly.

Eric said...

No worries. Glad to hear it has been fixed already :)

Alan Aversa said...

After playing around with a few URI regex plugins for Firefox that didn't work, this is the simplest, most elegant solution! Thank you!

I also like how I'm not going to have to go mobile for non-Blogspot.com sites. thanks again!

Eric said...

Glad to hear it helped :)

Alan Aversa said...

Actually, your method works with wordpress.com blogs, but doesn't appear to make blogspot.com blogs load the mobile versions. Appending "?m=1" to a blogspot.com URL forces it to load the mobile version, but I'm not sure how blogspot.com automatically checks for mobile clients; it appears to use something different than detecting a mobile useragent. Any ideas? thanks

G. said...

This option is no longer supported: https://bugzilla.mozilla.org/show_bug.cgi?id=933959

Eric said...

Thanks G.! I updated my post accordingly.