Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why can't I find the preference for the User Agent in Firefox?

462 views
Skip to first unread message

L.R.H.

unread,
Mar 10, 2016, 9:27:19 PM3/10/16
to mozilla-sup...@lists.mozilla.org
I'm just trying to set the User Agent Switcher and I can't
find where in prefs.js the value is set.

1. I save a copy of prefs.js as prefs.js.orig
2. I start up Firefox
3. I change the User Agent from whatever to whatever else.
4. I then kill Firefox
5. I compare the two prefs files:
$ diff prefs.js prefs.js.orig
< user_pref("browser.cache.disk.capacity", 358400);
> user_pref("browser.cache.disk.capacity", 215040);
< user_pref("datareporting.sessions.current.activeTicks", 4);
< user_pref("datareporting.sessions.current.clean", true);
> user_pref("datareporting.sessions.current.activeTicks", 1);
etc.

But there is nothing about the User Agent Switcher that seems
to be stored in the prefs.js file.

So, if I want to set the User Agent Switcher from the command
line ahead of time (with a script probably), *where* is the
preference set that tells Firefox what User Agent to display
to nosy web sites?

geo

unread,
Mar 11, 2016, 1:02:04 AM3/11/16
to mozilla-sup...@lists.mozilla.org


On 03/10/16 20:26, L.R.H. wrote:
<>

> So, if I want to set the User Agent Switcher from the command
> line ahead of time (with a script probably), *where* is the
> preference set that tells Firefox what User Agent to display
> to nosy web sites?
>
--

i do not believe 'User Agent Switcher' is written so as to accept profiles
from command line.

if you have need, for what ever reason, to go online with firefox with a
different user agent profile than default, either start firefox with
internet connection off, or when you close firefox, set it to offline
mode to see if such will stick when firefox is restarted.

you might check to see if any of the other user agent switcher add-ons
allows command line switching.

check for 'useragent' in 'about:config' to see the various 'preference
names' and if any relate to the 'user agent string'. i do not recall any.

failing that, gaagle or some good web search engine.



--
peace out.

If Bill Gates got a dime for every time Windows crashes...
...oh, wait. He does. THAT explains it!
-+-
in a world with out fences, who needs gates.

CentOS GNU/Linux 6.7

tc,hago.

g
..

Sanity Clause

unread,
Mar 11, 2016, 2:19:34 AM3/11/16
to mozilla-sup...@lists.mozilla.org
I'm still using 98SE with FF 3.6.26, so file locations may differ, especially
if you're using Linux, as "$ diff prefs.js prefs.js.orig" seems to say.

"L.R.H." wrote:

> 1. I save a copy of prefs.js as prefs.js.orig

Which of the many prefs.js are you using?
My search shows one in each of these 7 folders on my old machine:

C:\WINDOWS\Application Data\Mozilla\Firefox\Profiles\(unused profile).default
C:\WINDOWS\Application Data\Mozilla\Firefox\Profiles\(current profile).default
C:\WINDOWS\Application Data\Mozilla\Firefox\Profiles\(current profile).default\extensions\blahblah...
C:\WINDOWS\Application Data\Mozilla\Profiles\default\(some number).slt
C:\WINDOWS\Application Data\Thunderbird\Profiles\(a different number).default
C:\Program Files\Mozilla Firefox\defaults\profile
C:\Program Files\Mozilla Thunderbird\defaults\profile

The only one that changes when I play is the 2nd one.
It's also the biggest one.

I'm using the actual User Agent Switcher 0.7.3, which seems to default
to telling sites I'm using Windows 2000.

When I pretend I'm my Nokia C3-00, the UAS file shows 8 fields that can be filled,
(1 title plus 7 info) with only the 5th option shown below filled in.
Still, all 7 fields show up in the new prefs.js

user_pref("general.appname.override", "");
user_pref("general.appversion.override", "");
user_pref("general.platform.override", "");
user_pref("general.useragent.appName", " ");
user_pref("general.useragent.override", "NokiaC3-00/5.0 (03.35) Profile/MIDP-2.1 Configuration/CLDC-1.1
Mozilla/5.0 AppleWebKit/420 (KHTML, like Gecko) Safari/420");
user_pref("general.useragent.vendor", "");
user_pref("general.useragent.vendorSub", "");

When I switch back to UAS's "default" agent, those 7 lines vanish.

Any help at all? :)





VanguardLH

unread,
Mar 11, 2016, 7:01:28 AM3/11/16
to mozilla-sup...@lists.mozilla.org
Some extensions are extremely simple: they don't save preferences
because they are used for is to toggle a setting already in Firefox's
configuration (per profile). I use the No-Javascript Add-on extension
and it adds nothing that can be seen in about:config. That's because
all it does is toggle the javascript.enabled setting to True or False, a
setting already within Firefox.

Firefox's user agent setting (to override the hardcoded default) is:

general.useragent.override

So the Agent Switcher merely has to change the value of that setting.
If the default (hardcoded) is not overridden then this setting need not
exist which means Agent Switcher would have to create the setting and
then define its value all of which is still definitions within Firefox.

http://www.howtogeek.com/113439/how-to-change-your-browsers-user-agent-without-installing-any-extensions/

Shows how if the override setting is not present that it must be defined
and then assigned a value to do the override (of the inbuilt default).

User Agent Switcher's source code is hosted over at GitHub:

https://github.com/chrispederick/user-agent-switcher/

Yes, somewhere your selection would be recorded so that when the web
browser is exited and later reloaded that the same preferences gets
reused. After using User Agent Switcher to change away from the default
UA string after exiting Firefox, have you checked what was the value for
general.useragent.override? Have you used User Agent Switcher to change
to a non-default UA string and with Firefox left running (don't exit
after the UA change) then checked your prefs.js file to see if this
setting got created?

Do you have the Java plug-in installed? I've seen reports that it wipes
the UA setting on exit so you get the default on next load of Firefox.

Have you looked in the extensions own folder under your profile?

<yourFirefoxProfileFolder>/<extensionID>
which is probably:
%appdata%\Mozilla\Firefox\Profiles\<yourProfile>

That is where you find your prefs.js file. The extensions that are
installed in my profile for Firefox are under here in an "extensions"
subfolder. However, for example, uBlock Origin stores its data under
the extensions-data subfolder in an SQLite file.

https://github.com/chrispederick/user-agent-switcher/blob/master/development/source/content_common/useragentswitcher/options/options.js

That indicates the extension's options (settings) are exported and
imported from a file named useragentswitcher.xml.

https://bugzilla.mozilla.org/show_bug.cgi?id=933959

I'm not an expert on the internals of Firefox. That bug looks to report
that Mozilla deliberately nullified use of general.useragent.override to
be substituted by general.useragent.override.<site> site-specific
preference. That is, someone there decided that it was not appropriate
to change the UA string for every site that you visit, only for the
sites where you want to lie about your user agent to a particular site.
Although the bug has status "won't be fixed", it looks like the setting
might come back. I'm not sure where they are going in that bug thread.

https://www.autoitscript.com/forum/topic/180973-simple-way-to-change-firefox-useragent/

That author wrote his article only a couple weeks ago. It modifies the
general.useragent.override setting that you see (if defined) in
about:config. Alas, the author does not mention his version of Firefox.
If the override setting is now ignored then it may not show getting
changed in prefs.js. Instead the add-on has to change the "User-Agent:"
HTTP header on outbound connects. If indeed Mozilla yanked the override
setting (and if it's not coming back as a global setting) then perhaps a
UA changer would have to modify the HTTP header during session
initiation with the target site. That means the setting in about:config
is worthless so no point in storing it there.

L.R.H.

unread,
Mar 11, 2016, 11:39:03 AM3/11/16
to mozilla-sup...@lists.mozilla.org
Sanity Clause said:

> Which of the many prefs.js are you using?

It's not really what prefs.js "I" am using, but the question is more
of *where* does User Agent Switcher (0.7.3.1-signed) *put* it's preferences.

All I want to do is run a Linux script to randomly change those
preferences so that I have about 10 different User Agent strings
which Firefox will give to the various web sites.

My use model is simple:
1. I start firefox with a script
2. That script modifies the user agent preference file first
3. And then it invokes firefox

That way, I can control the user agent string with a text file:
For example:
UserAgentArray=(
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0" # Firefox 43.0
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1" # Firefox 40.1
"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0" # Firefox 36.0
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10; rv:33.0) Gecko/20100101 Firefox/33.0" # Firefox 33.0
"Mozilla/5.0 (X11; Linux i586; rv:31.0) Gecko/20100101 Firefox/31.0" # Firefox 31.0
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20130401 Firefox/31.0" # Firefox 31.0
"Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0" # Firefox 31.0
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0" # Firefox 29.0
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/29.0" # Firefox 29.0
"Mozilla/5.0 (X11; OpenBSD amd64; rv:28.0) Gecko/20100101 Firefox/28.0" # Firefox 28.0
)

The only question I have is *where* do I put the one randomly selected
User Agent string so that Firefox will give *that* (bogus) User Agent
to each web site that asks for it?

L.R.H.

unread,
Mar 11, 2016, 11:49:16 AM3/11/16
to mozilla-sup...@lists.mozilla.org
VanguardLH said:

> Some extensions are extremely simple: they don't save preferences
> because they are used for is to toggle a setting already in Firefox's
> configuration (per profile).

Wow. That was a great post, which will take me a lot more time to
go through than to just reply to this post, so, consider this just
the initial reply *before* I read and digest your helpful URLs.

Since this is just a quickie - I will reiterate that all I want to
do is have the user agent string be a different (random) string
which is set automagically for me. Period.

I don't want to manually have to mess with it.

I just want the string to be different each time, and, since not all
User Agent strings work well (e.g., I find Chrome strings cause problems
when using Firefox), I need to ensure the initial list of strings is
on the order of about a dozen good ones.

That's pretty much the simple use model that I want.

»Q«

unread,
Mar 11, 2016, 12:01:19 PM3/11/16
to mozilla-sup...@lists.mozilla.org
In
<news:mailman.187.1457714338...@lists.mozilla.org>,
"L.R.H." <l.r.h....@crimsontide.edu> wrote:

> It's not really what prefs.js "I" am using, but the question is more
> of *where* does User Agent Switcher (0.7.3.1-signed) *put* it's
> preferences.

> My use model is simple:
> 1. I start firefox with a script
> 2. That script modifies the user agent preference file first
> 3. And then it invokes firefox

For that use, don't need to involve an extension for that; you can
just have the script re-write user.js to set the
general.useragent.override pref.




L.R.H.

unread,
Mar 11, 2016, 12:10:37 PM3/11/16
to mozilla-sup...@lists.mozilla.org
VanguardLH said:

> Firefox's user agent setting (to override the hardcoded default) is:
> general.useragent.override

As you noted, that does not seem to *exist* anymore, at least not
through the about:config menu.

https://i.imgur.com/H8aa1Aw.gif

»Q«

unread,
Mar 11, 2016, 12:32:29 PM3/11/16
to mozilla-sup...@lists.mozilla.org
In
<news:mailman.190.1457716233...@lists.mozilla.org>,
"L.R.H." <l.r.h....@crimsontide.edu> wrote:

> VanguardLH said:
>
> > Firefox's user agent setting (to override the hardcoded default) is:
> > general.useragent.override
>
> As you noted, that does not seem to *exist* anymore, at least not
> through the about:config menu.

By default, it doesn't exist. You'd need to create it.

EE

unread,
Mar 11, 2016, 1:29:43 PM3/11/16
to mozilla-sup...@lists.mozilla.org
User Agent Switcher uses a file called useragentswitcher.xml, which is
put into the profile. You can download a file already loaded with fake
user agents using a link from the Options.

EE

unread,
Mar 11, 2016, 1:37:01 PM3/11/16
to mozilla-sup...@lists.mozilla.org
I made a little mistake. The file is useragents.xml. The other one is
a backup of that file.

L.R.H.

unread,
Mar 11, 2016, 1:40:30 PM3/11/16
to mozilla-sup...@lists.mozilla.org
»Q« said:

> For that use, don't need to involve an extension for that; you can
> just have the script re-write user.js to set the
> general.useragent.override pref.

This is a good idea, and simple to implement, "if" I get the syntax.

1. I started Firefox with a script
2. I typed about:config into the URL box
3. I searched for "general.useragent.override"
4. That did not exist.
5. I created "general.useragent.override" by right clicking "New string"
6. Enter the preference name = general.useragent.override
7. Enter string value = Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
8. At the command line in the profile directory I entered:
$ grep useragent prefs.js | grep -v browser.uiCustomization.state
user_pref("general.useragent.override", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0");
user_pref("useragentswitcher.import.overwrite", false);
user_pref("useragentswitcher.menu.hide", false);
user_pref("useragentswitcher.version", "0.73");
9. So I killed Firefox and put that first line into user.js
10. I started up firefox again & went to http://whatsmyuseragent.com
11. Drat. It failed.
12. That reported:
Mozilla/5.0 (X11; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/4CF0

I need to debug further because that should have worked.

Are you sure the general.useragent.override string can be set from
the user.js file?


L.R.H.

unread,
Mar 11, 2016, 1:47:44 PM3/11/16
to mozilla-sup...@lists.mozilla.org
EE said:

> User Agent Switcher uses a file called useragentswitcher.xml, which is
> put into the profile. You can download a file already loaded with fake
> user agents using a link from the Options.

For whatever reason, I can't seem to ever get User Agent Switcher to
simply randomly switch useragents.

Since some user agents make web pages horrid, I'd want to switch
automatically between only about a dozen user agent strings.

Does user agent switcher do that?
I can't make it do something that simple.

Maybe I'm using it wrong?

L.R.H.

unread,
Mar 11, 2016, 1:52:14 PM3/11/16
to mozilla-sup...@lists.mozilla.org
EE said:

> I made a little mistake. The file is useragents.xml. The other one is
> a backup of that file.

I found that file here:
$HOME/firefox/default_profile/useragentswitcher/useragents.xml

It contains zillions of lines of the form:
useragent="Mozilla/5.0 (X11; Linux i686 on x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 Fennec/2.0.1"
useragent="Mozilla/5.0 (Maemo; Linux armv7l; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 Fennec/2.0.1"
useragent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7 MG(Novarra-Vision/6.9)"
useragent="Mozilla/5.0 (BeOS; U; BeOS BePC; en-US; rv:1.9a1) Gecko/20060702 SeaMonkey/1.5a"

L.R.H.

unread,
Mar 11, 2016, 1:56:05 PM3/11/16
to mozilla-sup...@lists.mozilla.org
»Q« said:

> By default, it doesn't exist. You'd need to create it.

I created it, but it didn't take so something else must be screwing
it up (probably the User Agent Switcher settings):

$ grep -i useragent user.js
user_pref("dom.push.userAgentID", "");
user_pref("general.useragent.override", "Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/29.0");
// user_pref("general.useragent.override", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0");

$ grep -i useragent prefs.js | grep -v browser.uiCustomization.state
user_pref("useragentswitcher.import.overwrite", false);
user_pref("useragentswitcher.menu.hide", false);
user_pref("useragentswitcher.version", "0.73");

Maybe I should uninstall the user agent switcher?
(It's not automatically switching user agents anyway, so it's not
working like it's supposed to work.)

»Q«

unread,
Mar 11, 2016, 2:26:33 PM3/11/16
to mozilla-sup...@lists.mozilla.org
In
<news:mailman.199.1457721627...@lists.mozilla.org>,
"L.R.H." <l.r.h....@crimsontide.edu> wrote:

> »Q« said:
>
> > For that use, don't need to involve an extension for that; you can
> > just have the script re-write user.js to set the
> > general.useragent.override pref.

> Are you sure the general.useragent.override string can be set from
> the user.js file?

Yes. If I'd just been guessing, I would have mentioned that I was
guessing.

> user_pref("useragentswitcher.import.overwrite", false);
> user_pref("useragentswitcher.menu.hide", false);
> user_pref("useragentswitcher.version", "0.73");

If I were in your shoes, I'd make it work without that extension even
installed, then if necessary move on to making it work with the
extension.

VanguardLH

unread,
Mar 11, 2016, 8:10:16 PM3/11/16
to mozilla-sup...@lists.mozilla.org
Q wrote on 2016/03/11:

> "L.R.H." wrote:
>
>> VanguardLH said:
>>
>>> Firefox's user agent setting (to override the hardcoded default) is:
>>> general.useragent.override
>>
>> As you noted, that does not seem to *exist* anymore, at least not
>> through the about:config menu.
>
> By default, it doesn't exist. You'd need to create it.

According the bugzilla report, adding it does nothing. Existing and
having a value are ignored. The participants in the bug report say this
setting is gone. This has happened before and creating the setting and
defining it with a value does not make Firefox honor the setting.
Firefox won't use it anymore. I couldn't tell in the bug report if
Mozilla is bringing back that setting or sticking with site-specific
only UA overrides. So far, that bug report has status "WONTFIX" so
Mozilla has yet to determine if they will bring back that setting (so it
gets honored by Firefox).

https://bugzilla.mozilla.org/show_bug.cgi?id=933959

That is why I wonder how any UA extension would work anymore. Those
that rely on creating and/or altering this setting will fail to function
anymore. They would have to actively modify the "User-Agent:" HTTP
header that gets sent out.

»Q«

unread,
Mar 12, 2016, 12:04:28 AM3/12/16
to mozilla-sup...@lists.mozilla.org
In
<news:mailman.217.1457745012...@lists.mozilla.org>,
VanguardLH <V...@nguard.LH> wrote:

> Q wrote on 2016/03/11:
>
> > "L.R.H." wrote:
> >
> >> VanguardLH said:
> >>
> >>> Firefox's user agent setting (to override the hardcoded default)
> >>> is: general.useragent.override
> >>
> >> As you noted, that does not seem to *exist* anymore, at least not
> >> through the about:config menu.
> >
> > By default, it doesn't exist. You'd need to create it.

> This has happened before and creating the setting and defining it
> with a value does not make Firefox honor the setting. Firefox won't
> use it anymore.

Currently (45.0), it works.

geo

unread,
Mar 12, 2016, 1:23:37 AM3/12/16
to mozilla-sup...@lists.mozilla.org


On 03/11/16 12:55, L.R.H. wrote:
<>

> Maybe I should uninstall the user agent switcher?
> (It's not automatically switching user agents anyway, so it's not
> working like it's supposed to work.)
>
--

here is part of why i said do not uninstall.

amongst my playing with 'user.js', this is one i do believe you may
enjoy.

open firefox, open 'about:config', set 'search:' to 'useragent'.

locate and *insure* settings;

useragentswitcher.import.overide user set boolean true
useragentswitcher.menu.hide user set boolean false

close firefox.

open file browser to firefox profile directory. locate and rename your
current 'user.js' file to what ever you wish. create and paste following
into a new 'user.js' file:

=+=+=+=

//fn= user.js-prefs.t004
//path= /home/geo/Documents/system/mozilla/firefox
//date= 2015-0311-2215
//copyright= by author: g e leem - gnu gpl v.2 applies
//disable daily reporting of your addon metadata to mozilla servers
user_pref("extensions.getAddons.cache.enabled",false);
//set user agent to blank
user_pref("general.useragent.override", " ");

=+=+=+=

without the "=+=+=+=" and blank lines :-)

restart firefox, open a blank tab, paste this;

http://whatsmyuseragent.com/

into location bar, press enter.

i know, your ip address still shows. if you want to spoof that, use
a proxy server.

i am still playing with user agent randomizer script.
0 new messages