The User-Agent Switcher for Chrome

About the User-Agent Switcher for Chrome

What is the User-Agent Switcher for Chrome?

The user-agent switcher for Chrome is an extension for Google Chrome. It installs simply from the Google Chrome extension gallery, and shows as a button next to the omnibox.

Why would I want it?

This extension makes some sites work that don't usually work in Google Chrome. Installing this extension allows Google Chrome to access content intentionally or unintentionally blocked by the website.

Also, if you're building a site that needs to work in multiple browsers, you probably want to know what it looks like on a mobile device or a different platform without actually having that device or platform in front of you. It's useful for just taking a quick glance at how a site looks on a different platform.

What are the features of the user-agent switcher?
The user-agent switcher is an extension for Google Chrome.

It has the following features:

  • Change the user-agent and vendor strings on the fly right from the user-agent switcher's button in Chrome's UI.
  • Set a list of sites for the user-agent switcher to automatically switch user-agent strings.
  • Let the user-agent switcher automatically change the user-agent for sites with known user-agent string problems.
How does it work?

At the beginning of each site, the extension modifies the user-agent and vendor strings so any subsequent Javascript on the site will only see the modified strings.

The newer, experimental version also uses experimental APIs to modify HTTP headers sent to the site.

What does it not do?

The "old" user-agent switcher does not modify HTTP headers, which are another way for websites to detect user-agents. Not every site uses one method or another.

However, the "new" version available on this site does modify HTTP headers, so it should be a lot more effective.

Why doesn't the user-agent switcher modify HTTP headers?

The old version didn't because Chrome didn't support it. The new version does, though!

Who makes this thing?

The author is Glenn Wilson, and my Google plus profile can be found here.

How do I post bugs, or feature requests?

You can toss me a message on my plus profile.

For Webmasters

My site is on the 'known' list. Please remove it.

Fix your user-agent string parsing to work with Chrome, and we will happily remove it from the known offenders list. Please see the resources linked below on how to do that.

How do I fix my user-agent string parsing to work with Chrome?

Don't use user-agent sniffing to alter your site's behavior. Instead use object detection.

  • Browsers change behavior faster than ever before, so quirks that work in a browser today may not work tomorrow.
  • Building browser-quirk behavior into your sites makes them more brittle and unresponsive to new user-agents (think mobile phones!)
  • Detection methods are imprecise.

There are better ways to make your site behave appropriately for different rendering engines, specifically, object detection.

More information about browser detection versus object detection is here.

More information about improving your site's compatibility with Google Chrome is available here.

I don't have time to test my site on another browser, so things on my site may not work. I don't want users thinking my site supports it.

The user-agent switcher shows clearly when it is spoofing the user-agent string, and it makes no guarantees that sites will work when spoofing (many will work incorrectly when spoofing!)

But your users have spoken. They'd rather have a site that semi-works rather than a site that blocks them completely.

Making the time to test on Google Chrome and other browsers, along with modifying your site to not rely on user-agent string detection is an investment. As future user-agents arise, your site will scale automatically with them. You will be doing yourself a favor for the future.

The problem with my site is in someone else's JavaScript code I got from somewhere else. I have to use it and it's obfuscated, what do I do?

Update the code from the third party to the latest version. Most current versions detect and support Google Chrome correctly.

If they don't offer a version that supports detection of Google Chrome, there may be competing libraries you can use.