Tweaking Firefox User-Agent Value

Recently I noticed that on most of my comments, the browser detection plugin identifies my OS as Linux. When I went back and looked at some of my past comments, they were correctly identified as Ubuntu Linux. This confused me a little bit, so I decided to look at my User-Agent string.

In Firefox you can see the whole string by typing in about: in the address bar. In my case this was:

Mozilla/5.0 (X11;U;Linux i686;en-US;rv:1.8.1) Gecko/2006101022 Firefox/2.0

In the past I used Firefox 1.5 which came straight from the Hoary repository. Naturally, all official Ubuntu builds have an appropriate User-Agent variable set. Unfortunately the only Ubuntu version that gets an official FF 2.0 package is Edgy. Since I’m a huge Firefox fanboy I ended up downloading and using the generic Mozilla.org version which works fine, but it does not reflect my OS in the User-Agent string.

This bothered me a little because I kinda want to support my OS of choice by advertising it via the User-Agent. This way it ends up in people’s system logs, and gets included in statistical calculations and etc. But mostly I wanted to have the Ubuntu icon underneath my comments here on Terminally Incoherent.

How do you tweak your User-Agent string? The same way you change other Firefox config settings: about:config.

I personally simply changed the value of general.useragent.extra.firefox from Firefox/2.0 to Firefox/2.0 Ubuntu Linux. This was enough for my plugin to include the correct icon under my comments.

Now my User-Agent looks like this:

Mozilla/5.0 (X11;U;Linux i686;en-US;rv:1.8.1) Gecko/2006101022 Firefox/2.0 Ubuntu Linux

Of course this only changes a tiny part of the User-Agent string. You can completely override it by creating a new string value called general.useragent.override. You can essentially set your User-Agent to anything you want. Is that a good idea though? Nope! It’s horrible.

You see, a lot of websites use the User-Agent to serve you an appropriate stylesheet. Good web designers with complex layouts are likely have one stylesheet for IE, one for Gecko based browsers and Opera and one for “other”. The “other” stylesheet will likely be stripped down, and formated for legacy browsers – so in other words, it will likely look ugly. Not everyone does this, but if you start tweaking the User-Agent string to much, your browser may not be able to properly render some of the pages.

But if you don’t care about that, go ahead and knock yourself out. Now you know how. :mrgreen:

[tags]firefox, firefox 2.0, user agent, browser[/tags]

This entry was posted in technology and tagged . Bookmark the permalink.



7 Responses to Tweaking Firefox User-Agent Value

  1. Starhawk UNITED STATES Mozilla Firefox Ubuntu Linux says:

    Thanks. Good advice and a great tip.

    Reply  |  Quote
  2. Alex SPAIN Mozilla Firefox Ubuntu Linux says:

    Thank you :P

    Reply  |  Quote
  3. Luke UNITED STATES Mozilla Firefox SuSE Linux says:

    You’re welcome :)

    Reply  |  Quote
  4. Starhawk UNITED STATES Mozilla Firefox Ubuntu Linux says:

    OMG, I was looking around for a site to test my new useragent string (in Swiftweasel) on and found this rather old article, Jailed for using a nonstandard browser

    Reply  |  Quote
  5. Luke Maciak UNITED STATES Mozilla Firefox Windows Terminalist says:

    I remember reading about this back in the day. Very silly stuff. I wonder how this all turned out in the end. I don’t think I ever saw a followup on this story.

    Reply  |  Quote
  6. Starhawk UNITED STATES Mozilla Firefox Ubuntu Linux says:

    I never found a follow up either not that I looked much but I suspect the charges were dropped and if he was a litigious type, he sued. Hopefully he won too :)

    Reply  |  Quote
  7. Sometimes I set my user agent to Googlebot to get past paywalls or registration walls. Some websites serve up a different page for Googlebot because they want to keep their paywall but also have their page indexed at the same time. Sorry, it doesn’t work that way.

    This is called cloaking, and when Google catches people doing this they get penalized in search results. You can get past cloaking by looking in the Google cache too.

    It’s surprising how many websites do search engine cloaking like that.

    Reply  |  Quote

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>