27

I have to use a particular web site for work, but this web site checks to see whether I'm using Internet Explorer and, if not, won't allow me to log in. I can switch my User-Agent header using the User Agent Switcher Firefox plugin and the web site works fine, but I really don't want to switch the header every time I go to the site and also don't want my User-Agent header to perpetually say I'm using IE.

I'm on Linux, so actually switching to IE unfortunately isn't an option.

Is there any way to define a particular User-Agent for a particular web site in either Firefox or Chrome?

0

7 Answers 7

18

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

1
  • Does this allow for wildcards? If so, what's the format? I think it hasn't worked when I tried * for the domain.
    – David
    May 3, 2021 at 6:46
12

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.

2
  • I changed this to match with facebook.com and youtube.com, but it didn't work. I heard that you can't change the user agent via userscript since it only effects after the site is loaded, while the information about user agent should be sent beforehand. Is this true?
    – Ooker
    Jul 1, 2017 at 11:14
  • 1
    UAControl is no longer available for Firefox, but the Mozilla-recommended extension User-Agent Switcher and Manager can be used as an alternative. Enable and configure "Custom Mode" in the extension settings to use it on a per-domain basis.
    – tanius
    Jul 31, 2021 at 13:23
8

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.

4
  • Do you know if it works per site or per-domain? I am trying to match google.com/search and it doesn't work, but maybe google is doing some JS-based check.
    – njsg
    Mar 16, 2013 at 17:44
  • It looks like you are able to apply specific rules for subdomains, so the answer to your questions depends on the definition of "site". Anyway, trying to match 'google.com/search' would require path matching which is out of scope for both site and domain matching. There might be another solution that fits your needs in this case, but it depends on what you are trying to achieve. Mar 17, 2013 at 13:11
  • Well, then it won't work. Ended up doing it for www.google.com, which also affects calendar. What I wanted was to change the user-agent used for Google Web and Image search, so that it uses the non-AJAXy fallback version instead. Their search does effectively live under google.com/search. But I guess there would be more cases where more than domain matching would be useful. There are way too many sites which don't have their own domain, or which provide completely separate services under the same domain.
    – njsg
    Mar 18, 2013 at 8:23
  • I agree with you that it would be a nice bonus, but it probably is hard to implement and might be confusing for many users. Regarding your search issue: Would webapps.stackexchange.com/questions/6809/… be an acceptable alternative? Another way would be to use some country-code domain for searching, e.g. google.ch. Mar 18, 2013 at 18:02
4

There are many extensions you can use which can work by auto detecting the IE setting for the website on FF.

IE TabV2

The updated, fully supported IE Tab. Embed IE in a Firefox tab.
IE Tab Features: FF 4+ support, IE 7-9 compatibility modes, old IE Tab settings import. IE Tab supports ICBC and alipay

IE Tab Plus

The Original IE-Tab (Works also for IE8, IE9)

An enhanced version of IE Tab with Adblock Plus in IE supported. It also allows you import settings from IE Tab and synchronize cookies between IE and Firefox.

Only IE-Tab to support FF4 and beyond

1
  • Darn, beat me to it. ;) +1 for being more thorough than I was, too.
    – techturtle
    Jun 20, 2012 at 15:57
2

You can use an addon like IE-tab, which will actually use IE DLLs from within Firefox, so the page will not only think you are using IE but it will render the same. It can be set to automatically apply when you visit specific pages, so that you get Firefox rendering on everything except the sites that require IE.

1
  • +1 thanks for the suggestion but I have IE disabled so I'm not sure whether this one is for me.
    – nikhil
    Jun 20, 2012 at 15:57
0

Here's what I did in FireFox:

  1. Used UserAgentSwitcher Addon to spoof myself as an iphone. Visited site I always want to load the mobile version of, and it automatically loaded the mobile version.

  2. Made a bookmark to the site's mobile page.

  3. Set UAcontrol Addon to use iphone useragent on the site.

  4. Turned off UserAgentSwitcher.

When I launch the site from the regular bookmark it uses the regular website. And when I launch the site from the mobile version bookmark, it uses the mobile version.

Thus... UserAccountSwitcher functionality localized to one site rather than globally.

3
  • What is the benefit of also using UserAgentSwitcher instead of just UAControl alone? Aug 13, 2012 at 18:02
  • Assuming you don't want the user agent switched globally, nothing. I only used UserAgentSwitcher in my steps above because I needed to grab the iphone user agent as I didn't know what it was.
    – karl
    Aug 16, 2012 at 4:06
  • In the last sentence, did you really mean UserAccountSwitcher? Sep 17, 2012 at 11:40
0

I needed to switch user agent to fix low resolution images in Firefox on Android. I found a lot of dead links to agent switchers, but this one worked in Firefox - even on Android: User Agent Switcher:

https://addons.mozilla.org/sv-SE/firefox/addon/user-agent-string-switcher//firefox/addon/user-agent-string-switcher/

1
  • Aaand... Is also dead now. Nov 15, 2023 at 15:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .