Friday, April 27, 2012

Custom User Agent in Chrome

This must be the coolest thing ever. :) There was this very annoying thing with Google Chrome on Linux where Google servers would redirect my request for to the mobile version of the site and then, immediately, to Places instead of Maps. There was just no way to get the map view in the perfectly valid browser.
I analyzed the messages exchanged between the browser and the server and thought the server might be confused by the User Agent setting. Especially because everything worked perfectly fine in Firefox on the same machine. And I could open maps on the Android smartphone being used to relay the connection.
So, Open Source devs to the rescue. There is a command-line option to set the User Agent when starting Chromium-based browsers. It is as simple as running

google-chrome --user-agent="Firefox/3.5.5"

or whatever else you want. More appropriate would, probably, be to use "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6" as that is the user agent string for one of the later Chrome browsers on Windows.

No comments: