Can I switch the User-Agent header for only a single web site?

The extension User-Agent Switcher for Chrome has a Permanent Spoof list, where you can set specific user agents for certain domains.

Configuration

  1. Add the extension to Chrome.

  2. Open chrome-extension://djflhoibgkdhkhhcedjiklpkjnoahfmg/options.html.

  3. Click Permanent Spoof list.

  4. Enter the domain of the particualr website, select the desired user agent and click Add.

screenshot


Until Firefox 25, one could set general.useragent.override.[domain] to a custom UA string. Unfortunately, this feature was removed in Firefox 25.

Now, to get per-site UA string, one could install UAControl plus User-Agent JS Fixer. The first add-on modifies the User-Agent request header per site, but not the navigator.userAgent string that is often used for UA-sniffing. The second add-on complements the first add-on by overriding navigator.userAgent.

Since I already had Greasemonkey installed, and the site I'm targetting only uses client-side User-Agent sniffing, I decided to write a small user script to change navigator.userAgent for this particular site:

// ==UserScript==
// @name        Change navigator.userAgent
// @namespace   Rob W
// @description Changes navigator.userAgent to IE on IEGallery.com
// @match       http://www.iegallery.com/*
// @run-at      document-start
// @grant       none
// @version     1
// ==/UserScript==

Object.defineProperty(navigator, 'userAgent', {
    value: 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)'
});

Works like a charm in Firefox 26.0.


For Firefox there are the extensions UAControl and ua-site-switch, which allow setting the User-Agent header on a per-site basis. Pick one of them and, as Rob W pointed out, you'll need to install User-Agent JS Fixer too.