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]