Wednesday, September 17, 2008

How to Change User Agent String in Google Chrome Browser

Source: http://www.labnol.org/software/change-google-chrome-user-agent-string/4566/

iphone user agent for google chome You can do lot of interesting things on the web if you know how to modify the user-agent string of a web browser. For instance, change the Chrome user-agent string to that of iPhone Safari and you’ll be to read popular magazines for free.

Or change the user-agent to Googlebot and you get to read Wall St. Journal stories without subscribing. Or use the user-agent of Opera Mini phone browser and see mobile versions of web pages even on the desktop.

While it is relatively easy to edit the User-Agent string of Firefox, IE, Flock or Apple Safari through add-ons and registry hacks but you don’t have that luxury in Chrome since Google’s browser doesn’t support external add-ons yet.

google-chrome-magazines
iPhone version of Zinio Magazines in Google Chrome

It is however possible to change the user-agent of Google Chrome via the following hack - open Chrome.dll file inside a Hex viewer, search for the Chrome User Agent string and overwrite (not insert) that with the user-agent of another browser.  Thanks Ramzalot.

chrome-agent

Here are the full steps involved:

0. Make a backup of chrome.dll file - the file is available in the 0.2.xx folder of your Chrome installation folder (refer to #2).

1. Open chrome.dll inside Xvi32 and search for a patten that matches the default user agent string for Google Chrome :

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.X.Y.Z Safari/525.13.

chrome-user-agent

2. Point the cursor to the letter M and choose Edit -> Overwrite String. Paste the user-agent of any other browser here. For instance, the strings for iPhone and Google spiders are:

Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3

Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

3. Close Google Chrome (if running) and then save the chrome.dll file inside the hex editor. Restart chrome.exe and type about: in the address bar to confirm if the user agent has changed. If you have trouble opening chrome after making the above changes, just delete the modified chrome.dll file and replace it with the old backup.

 google-iphone-version
iPhone mobile version of Google Reader in Google Chrome

As an example, I change the user agent of Google Chrome to iPhone and that is the reason why Google opening the iPhone optimized version of Google Reader even inside Chrome.

If you plan to use this trick more frequently, a better option is that you create multiple copies of chrome.dll - one per user agent. Now if you want Chrome to emulate IE or Firefox, just make rename the chrome-firefox.dll or chrome-iphone.dll to chrome.dll.

Related: Add Google Mobile Sites to Firefox Sidebar

How to Change User Agent String in Google Chrome Browser - Digital Inspiration