MozillaZine

domain-specific user agent override supported or not?

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

Post Posted June 15th, 2017, 6:35 am

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 viewtopic.php?p=14069201#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

LIMPET235
Moderator

User avatar
 
Posts: 37613
Joined: October 19th, 2007, 1:53 am
Location: The South Coast of N.S.W. Oz.

Post Posted June 15th, 2017, 7:07 am

Moving to Firefox Support...
Ancient Amateur Astronomer
Win-7-HP/Intel® DualCore-2.0GHz/500G HDD/4 Gig Ram/550Watt PSU/350WattUPS/Firefox-20.0-56.0.1/T-bird-2.0.0.24/SnagIt-v10.0.1/MWP-7.11.0.
RadioYachting.
(Always choose the "Custom" Install.)

Brummelchen
 
Posts: 2591
Joined: March 19th, 2005, 10:51 am

Post Posted June 15th, 2017, 11:06 am

why do you need to fake UA to chrome?

PSD
 
Posts: 3
Joined: June 15th, 2017, 6:20 am

Post Posted June 15th, 2017, 1:06 pm

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.

RobertJ
Moderator

User avatar
 
Posts: 10239
Joined: October 15th, 2003, 7:40 pm
Location: Chicago IL/Oconomowoc WI

Post Posted June 15th, 2017, 1:24 pm

.
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 57.0 - FF 58b4 - Palemoon 27.3.0 - TB 52.4 - Mac OSX 10.13.1
Computers I've used: IBM 7094/UNIVAC 1108/IBM 360/DEC PDP11/DEC VAX-11 780/DEC VAXstation 8000/Sun SPARCstation 2/Mac from 1984 to 2017

PSD
 
Posts: 3
Joined: June 15th, 2017, 6:20 am

Post Posted June 15th, 2017, 2:15 pm

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.

RobertJ
Moderator

User avatar
 
Posts: 10239
Joined: October 15th, 2003, 7:40 pm
Location: Chicago IL/Oconomowoc WI

Post Posted June 15th, 2017, 2:33 pm

.
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 57.0 - FF 58b4 - Palemoon 27.3.0 - TB 52.4 - Mac OSX 10.13.1
Computers I've used: IBM 7094/UNIVAC 1108/IBM 360/DEC PDP11/DEC VAX-11 780/DEC VAXstation 8000/Sun SPARCstation 2/Mac from 1984 to 2017

morat
 
Posts: 2447
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 15th, 2017, 4:49 pm

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

RobertJ
Moderator

User avatar
 
Posts: 10239
Joined: October 15th, 2003, 7:40 pm
Location: Chicago IL/Oconomowoc WI

Post Posted June 16th, 2017, 6:54 am

.
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 57.0 - FF 58b4 - Palemoon 27.3.0 - TB 52.4 - Mac OSX 10.13.1
Computers I've used: IBM 7094/UNIVAC 1108/IBM 360/DEC PDP11/DEC VAX-11 780/DEC VAXstation 8000/Sun SPARCstation 2/Mac from 1984 to 2017

morat
 
Posts: 2447
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 16th, 2017, 7:22 am

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.

dickvl

User avatar
 
Posts: 52279
Joined: July 18th, 2005, 3:25 am

Post Posted June 16th, 2017, 4:29 pm

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: 2447
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 16th, 2017, 5:43 pm

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

Return to Firefox Support


Who is online

Users browsing this forum: Google [Bot], Happy112, LIMPET235 and 16 guests