domain-specific user agent override supported or not?

User Help for Mozilla Firefox
Post Reply
PSD
Posts: 3
Joined: June 15th, 2017, 6:20 am

domain-specific user agent override supported or not?

Post by PSD »

Hi,

From what I've read, the general.useragent.override.site_specific_overrides was at some point removed from Firefox but re-added in a later version. According to http://forums.mozillazine.org/viewtopic ... #p14069201 it was working in version 37beta4.

I'm using version 54.0 but I cannot get this feature to work. I have the following settings:

general.useragent.site_specific_overrides;true
general.useragent.override.itvonline.nl;Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36

but it doesn't work. According to the Developer Tools panel (F12) the Request Header that is sent when I visit that domain is simply the default Firefox user-agent. The global general.useragent.override does work but I only want to use it for this domain.

I know there are some Add-Ons that claim to be able to do this but I would prefer a solution using the built-in features of Firefox, if they still exist.

Thanks,
Arjan
User avatar
LIMPET235
Moderator
Posts: 39932
Joined: October 19th, 2007, 1:53 am
Location: The South Coast of N.S.W. Oz.

Re: domain-specific user agent override supported or not?

Post by LIMPET235 »

Moving to Firefox Support...
[Ancient Amateur Astronomer.]
Win-10-H/64 bit/500G SSD/16 Gig Ram/450Watt PSU/350WattUPS/Firefox-115.0.2/T-bird-115.3.2./SnagIt-v10.0.1/MWP-7.12.125.

(Always choose the "Custom" Install.)
Brummelchen
Posts: 4480
Joined: March 19th, 2005, 10:51 am

Re: domain-specific user agent override supported or not?

Post by Brummelchen »

why do you need to fake UA to chrome?
PSD
Posts: 3
Joined: June 15th, 2017, 6:20 am

Re: domain-specific user agent override supported or not?

Post by PSD »

Because our Internet/telephony/IPTV provider (KPN) has a stupid and unneccessary check for Firefox that redirects it to a landingpage that says Firefox is not supported (they do support some other browsers such as Chrome through plain HTML5 for online TV watching) which is patent nonsense. It works perfectly with Firefox as well if you fake the UA.

They used to support Firefox through SilverLight but Firefox works just fine with their current HTML5 solution.

The website in question is www.itvonline.nl but you won't be able to actually watch anything if you're not connecting directly through a KPN broadband internet connection.

I'm now using the UAControl Add-On but it seems silly to need an Add-On if there is (or was) built-in support for setting domain-specific User-Agent.
User avatar
RobertJ
Moderator
Posts: 10880
Joined: October 15th, 2003, 7:40 pm
Location: Chicago IL/Oconomowoc WI

Re: domain-specific user agent override supported or not?

Post by RobertJ »

.
Yes. Go into about:config and create an entry (right click) with the following

Type String

Preference Name --> general.useragent.override.itvonline.nl

Value --> Chrome UA string

If you don't know what it is you can find out here

http://www.whoishostingthis.com/tools/user-agent/

.
FF 92.0 - TB 78.13 - Mac OSX 10.13.6
PSD
Posts: 3
Joined: June 15th, 2017, 6:20 am

Re: domain-specific user agent override supported or not?

Post by PSD »

RobertJ wrote:.
Yes. Go into about:config and create an entry (right click) with the following

Type String

Preference Name --> general.useragent.override.itvonline.nl

Value --> Chrome UA string

If you don't know what it is you can find out here

http://www.whoishostingthis.com/tools/user-agent/

.
I already tried that, see my OP. It's not working. Only the global entry general.useragent.override works, not the per-domain entries.
User avatar
RobertJ
Moderator
Posts: 10880
Joined: October 15th, 2003, 7:40 pm
Location: Chicago IL/Oconomowoc WI

Re: domain-specific user agent override supported or not?

Post by RobertJ »

.
Strange. I have four domain specific overrides and they all work. Here is an example

Code: Select all

general.useragent.override.mybank.com  -->  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4
My bank doesn't like Firefox on a Mac so I pretend I'm using Safari [which is garbage]. It works just fine as do three others I have set in about:config

.
FF 92.0 - TB 78.13 - Mac OSX 10.13.6
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: domain-specific user agent override supported or not?

Post by morat »

I can't get it to work. I tried clearing my Fx cache... still can't get it to work.

Test prefs:

general.useragent.site_specific_overrides = true
general.useragent.override.chrispederick.com = Mozilla/5.0 (Windows NT 6.1; rv:40.0) Gecko/20100101 Firefox/40.0
general.useragent.override.httpbin.org = Mozilla/5.0 (Windows NT 6.1; rv:50.0) Gecko/20100101 Firefox/50.0

Test pages
http://chrispederick.com/work/user-agen ... ures/test/
http://httpbin.org/

The general.useragent.override pref works correctly.

Firefox Portable 54.0
Windows 7 SP1 32-bit
User avatar
RobertJ
Moderator
Posts: 10880
Joined: October 15th, 2003, 7:40 pm
Location: Chicago IL/Oconomowoc WI

Re: domain-specific user agent override supported or not?

Post by RobertJ »

.
My bad. I use SeaMonkey and general.useragent.override.somesite.com works fine (assumed same for FF). Wrong. Just tested it and it does not work in FF. :oops:

.
FF 92.0 - TB 78.13 - Mac OSX 10.13.6
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: domain-specific user agent override supported or not?

Post by morat »

The UserAgentOverrides module has been stripped out.

UserAgentOverrides take ~9% of pageload time...
http://bugzilla.mozilla.org/show_bug.cgi?id=896114

For reading only as Bugzilla is not a forum.
User avatar
dickvl
Posts: 54145
Joined: July 18th, 2005, 3:25 am

Re: domain-specific user agent override supported or not?

Post by dickvl »

The module is still there, but only not initialized anymore.
resource://gre/modules/UserAgentOverrides.jsm

https://dxr.mozilla.org/mozilla-release ... rrides.jsm
https://dxr.mozilla.org/mozilla-release ... rides.html

I can get it to work if I run this code in the Browser Console.

Code: Select all

Components.utils.import("resource://gre/modules/UserAgentOverrides.jsm");
UserAgentOverrides.init();
Testing user agent on the BrowserSpy website.
http://browserspy.dk/useragent.php

general.useragent.override.browserspy.dk =
Full override:
Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Firefox/52.0
RegExp override:
(rv:|Firefox/)\d{2}#$152

Reported:
UserAgent from header Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Firefox/52.0
User Agent from JavaScript Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Firefox/52.0
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: domain-specific user agent override supported or not?

Post by morat »

Nice catch :)

I got it working after running the init code.

PSD could add the init code to the mozilla.cfg file.

e.g.

* C:\FirefoxPortable\App\Firefox\defaults\pref\autoconfig.js

Code: Select all

// autoconfig.js file needs to start with a comment

pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0);
* C:\FirefoxPortable\App\Firefox\mozilla.cfg

Code: Select all

// mozilla.cfg file needs to start with a comment line

var userAgent = "Mozilla/5.0 (Windows NT 6.1; rv:50.0) Gecko/20100101 Firefox/50.0";

pref("general.useragent.override.browserspy.dk", userAgent);

Components.utils.import("resource://gre/modules/Services.jsm");

Services.obs.addObserver(function (aSubject, aTopic, aData) {
  var chromeWindow = aSubject;
  chromeWindow.setTimeout(function () {
    Components.utils.import("resource://gre/modules/UserAgentOverrides.jsm", chromeWindow);
    chromeWindow.UserAgentOverrides.init();
  }, 1000);
}, "browser-delayed-startup-finished", false);
Customizing Firefox – Advanced Autoconfig Files
http://mike.kaply.com/2012/03/22/custom ... fig-files/

Demo mozilla.cfg file
http://mike.kaply.com/wp-content/blogs. ... 2/demo.cfg

Observer Notifications
http://developer.mozilla.org/en-US/docs ... ifications

Deploying Firefox in an enterprise environment
http://developer.mozilla.org/en-US/Fire ... deployment
Post Reply