Monday, 4 January 2016

How-to: Change Your Browser’s User Agent Without Installing Extensions


Every web browser presents a user-agent string, to identify the browser, version number and usually the platform it's on, whenever it connects to a web server. It's a shorthand route to match the versions of web pages to the device requesting them.

For various reasons of compatibility, feature sets and bandwidth usage, you might prefer your browser to identify itself as something other than it's true identity, in which case you might want to change the user agent string.

The user agent is a way for a browser to declare, for example, 'I’m Mozilla Firefox 24.0 on Windows' or 'I’m Safari 6.0 on iPhone 6' to a web server, so that it can choose to serve an appropriate web page appropriate to the browser and operating system.

Depending on the user agent string presented, the web-server would serve mobile pages to mobile browsers, modern pages to modern browsers, and a 'you gotta be kidding me, really? Get the f* outta here' message to anyone still on Internet Explorer 6. If only.

Over the years, however, the user agent strings have become a bit of a mess. You can find a list online of the user agent strings. It is vast, confusing and not always helpful or useful to web servers.

Fortunately, all the popular browsers offer build-in user agent switchers, enabling you can change your user agent without installing any extensions. Unfortunately, they're not all in the same place, or all that easy to find. If we look at Chrome, IE and Firefox, we'll see it done slightly differently either in developer tools or user options.

Google Chrome
  • The user agent switcher is part of Chrome’s Developer Tools; open the  hamburger menu, select Tools, then Developer tools (or use the Ctrl-Shift-I keyboard shortcut).
  • Select the 'Show console' icon. Go to the 'Emulation' tab. 
  • If prompted with a message that says 'Emulation is currently disabled', click the 'Enable emulation' button. 
  • Select 'Network' in the left menu of the Developer console. There you can set the 'Spoof user agent' box to the User Agent you wish to use; it will show you the user agent plain text in the Other box; you can enter your own free text string by selecting 'Other'.
Sadly this setting persists only as long as you have the Developer Tools window open; close it and Chrome will revert to its default user agent.

Internet Explorer 11
  • Internet Explorer also has the user agent option under developer tools. 
  • Hit F12 or from the Tools menu, select the Developer tools option .
  • Select the Tools menu in the developer tools pane, select 'Change user agent string' top open the user agent list and select one.
  • You can also select the Custom option and add a custom user agent string to the list.
This setting is also temporary. Internet Explorer reverts to its default user agent when the session ends.

Mozilla Firefox
  • Mozilla Firefox doesn’t provide for changing its user agent, you have to edit the Firefox about:config page. This is so dangerously like editing the Windows Registry, that if you enter about:config into Firefox’s address bar, it will throw a warning.
  • Type useragent into the filter box. The general.useragent.override preference isn't loaded by default, so you will probably have to create it yourself
  • Right-click on the about:config page, select New, then select String.
  • In the pop-up box, create the preference general.useragent.override
  • The next popup is for the user agent string value, for example
    Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
  • This setting persists from now on, for all sessions until you change it.
  • To revert Firefox to the default user agent, right-click the, return to about:config, right-click on the general.useragent.override preference and select Reset; this blanks the override string.

With these limitations, you can see why there are extensions and plugins to manage and make permanent any change to user agents you might make. RC

Image credit: Cat Spy by Dwight Sipler and Kjetil Ree / Wikimedia Commons

No comments:

Post a Comment

At least try to be nice, it won't kill you...