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

Why does this user.js cause all other commands to be skipped?

19 views
Skip to first unread message

Hans Donitz

unread,
Apr 14, 2016, 2:03:37 AM4/14/16
to mozilla-sup...@lists.mozilla.org
Why does this user.js line cause all other commands to be skipped?
user_pref(“browser.shell.checkDefaultBrowser”, false);// Turn off default browser checking

1. I noticed that my user.js wasn't being completely read by Firefox 43.
2. To debug, I scattered a dozen lines of the format below throughout the user.js:
$ grep readthis user.js
user_pref("readthis.user.js", 1);
user_pref("readthis.user.js", 2);
user_pref("readthis.user.js", 3);
... and so on ...
user_pref("readthis.user.js", 12);
3. And then I'd start Firefox, and about:conf look for which "readthis" made the cut.
4. By moving the lines above about, I found the *exact* line where Firefox *stopped* reading the user.js
user_pref("readthis.user.js", 5);
user_pref(“browser.shell.checkDefaultBrowser”, false);// Turn off default browser checking
user_pref("readthis.user.js", 6);
5. When I commented out that line, the "readthis" test made it to the bottom!
user_pref("readthis.user.js", 5);
//user_pref(“browser.shell.checkDefaultBrowser”, false);// Turn off default browser checking
user_pref("readthis.user.js", 6);

So, my question is what is wrong with that line?

user_pref(“browser.shell.checkDefaultBrowser”, false);// Turn off default browser checking

Specifically, why does it prevent Firefox from loading user.js any further?



Jim Porter

unread,
Apr 14, 2016, 2:06:41 AM4/14/16
to mozilla-sup...@lists.mozilla.org
On 04/14/2016 01:03 AM, Hans Donitz wrote:
> Why does this user.js line cause all other commands to be skipped?
> user_pref(“browser.shell.checkDefaultBrowser”, false);// Turn off default browser checking

Because that's invalid syntax. Somehow you ended up inserting Unicode
quotation marks (“”) instead of ASCII ones (").

Wouldn't it work better to simply edit prefs via about:config anyway?
Then you don't have to worry about this stuff.

- Jim

»Q«

unread,
Apr 14, 2016, 2:28:36 AM4/14/16
to mozilla-sup...@lists.mozilla.org
In
<news:mailman.273.1460613816...@lists.mozilla.org>,
Hans Donitz <hansd...@yahoo.com> wrote:

> Why does this user.js line cause all other commands to be skipped?
> user_pref(“browser.shell.checkDefaultBrowser”, false);// Turn off default browser checking

Because the quote marks are bad. Change them to ASCII quote marks:

Hans Donitz

unread,
Apr 14, 2016, 2:29:27 AM4/14/16
to mozilla-sup...@lists.mozilla.org
Jim Porter wrote:

>> Why does this user.js line cause all other commands to be skipped?
>> user_pref(“browser.shell.checkDefaultBrowser”, false);// Turn off default browser checking
>
> Because that's invalid syntax. Somehow you ended up inserting Unicode
> quotation marks (“”) instead of ASCII ones (").

Holy Geesiz lover of God!

How did you realize that?

You're correct, by the way.
$ grep "”" user.js
user_pref(“browser.shell.checkDefaultBrowser”, false);// Turn off default browser checking

$ vi user.js
(change the ” to ")

$ firefox
about:config
readthis

Voila!
readthis.user.js;12

Two questions:
Q1: How (the heck) did you realize that?
(I stared at it for a long while and didn't even notice that!)

Q2: Why would a unicode double quote cause the end of a user.js to occur?
(Is that a bug?)

> Wouldn't it work better to simply edit prefs via about:config anyway?
> Then you don't have to worry about this stuff.

My user.js file is a thousand lines long; manual additions would take forever!
$ wc -l user.js
913 user.js

For example, I use this as my starting point for user.js:
http://www.ghacks.net/2015/08/18/a-comprehensive-list-of-firefox-privacy-and-security-settings/

$ wc -l user.js_[ghacks]-0.08.js
855 user.js_[ghacks]-0.08.js

So, I manually add only 58 items (913-855=58); but even adding 58 items
is still easier done by typing into user.js.

I am going to guess that I must have cut-and-pasted from a web page the
errant doublequotes quite some time ago and didn't notice my error.

But, is it a "bug" that doublequotes kill user.js so effectively?

Note: It's a neat way to comment out the rest of the file! :)

Hans Donitz

unread,
Apr 14, 2016, 2:36:45 AM4/14/16
to mozilla-sup...@lists.mozilla.org
»Q« wrote:

>> Why does this user.js line cause all other commands to be skipped?
>> user_pref(“browser.shell.checkDefaultBrowser”, false);// Turn off default browser checking
>
> Because the quote marks are bad. Change them to ASCII quote marks:
> user_pref("browser.shell.checkDefaultBrowser", false);// Turn off default browser checking

Thank you for helping me out!
I justed tested that suggestion and both you and Jim Porter are correct.

Who knows how long the errant quotes have been there, as I only noticed today
that the user.js wasn't being read to the end.

I'm guessing I cut and pasted from some web page somewhere, and then forgot
about it (and didn't realize that it killed the rest of the user.js file!).

I'm surprised you both instantly figured out the problem, as I couldn't, for
the life of me, understand what was wrong with the line.

(How did you realize that was the problem?)

BTW, do you consider it a bug that a mere "wrong" quote kills the rest of
the user.js file?

»Q«

unread,
Apr 14, 2016, 2:47:43 AM4/14/16
to mozilla-sup...@lists.mozilla.org
In
<news:mailman.274.1460615364...@lists.mozilla.org>,
Hans Donitz <hansd...@yahoo.com> wrote:

> Jim Porter wrote:
>
> >> Why does this user.js line cause all other commands to be skipped?
> >> user_pref(“browser.shell.checkDefaultBrowser”, false);// Turn off
> >> default browser checking
> >
> > Because that's invalid syntax. Somehow you ended up inserting
> > Unicode quotation marks (“”) instead of ASCII ones (").
>
> Holy Geesiz lover of God!
>
> How did you realize that?

I'm not Jim, but using an editor with syntax highlighting makes it a
lot easier to spot, well, syntax errors.

> $ vi user.js

I'm certain there's a way to turn on .js syntax highlighting in vi, but
I don't know how -- my vim has it on by default, so I never have had to
learn how to enable/disable it.

> Q2: Why would a unicode double quote cause the end of a user.js to
> occur? (Is that a bug?)

I don't think it's a bug, but any syntax error does cause reading to be
stopped.

»Q«

unread,
Apr 14, 2016, 4:00:00 AM4/14/16
to mozilla-sup...@lists.mozilla.org
In
<news:mailman.275.1460615802...@lists.mozilla.org>,
The quotes in your post just didn't look right to me -- they were
slanty. I read news posts in Dejavu Sans Mono, which is the same font I
use for editing text files. The unicode quotes don't look a lot
different, but they do look different.

It was also probably easier to spot that kind of thing because I was
just looking at a single line, not a line surrounded by hundreds of
similar lines as you were.

With hundreds of lines in your user.js, you definitely want syntax
highlighting in your editor

> BTW, do you consider it a bug that a mere "wrong" quote kills the
> rest of the user.js file?

I think it's actually a safeguard against reading a corrupted .js file,
but I'm not sure. Whether it's a bug or not, it's the way it always has
been and always will be, so you just have to live with it.

The following is based on a great idea from Hartmut Figge in the
SeaMonkey group; it makes it easy to tell whether there's a syntax
error simply by looking at about:config.

Make the first line of your user.js

user_pref("00-user.js-canary", "canary dead due to syntax error in user.js");

and make the last line

user_pref("00-user.js-canary", "canary lives -- user.js was read to the end");

The first line will always be read; the last line will override
the first line if and only if all the syntax in your user.js is ok.

Hans Donitz

unread,
Apr 14, 2016, 9:25:08 AM4/14/16
to mozilla-sup...@lists.mozilla.org
»Q« wrote:

> The quotes in your post just didn't look right to me -- they were
> slanty.

Well, your eyes, and those of Jim Porter, are more discerning than mine,
which I appreciate.

> With hundreds of lines in your user.js, you definitely want syntax
> highlighting in your editor

I don't edit the user.js all that often. Just when a new Firefox
comes out, and then I find more privacy invasion stuff I have to
make disappear. :)

> I think it's actually a safeguard against reading a corrupted .js file,
> but I'm not sure. Whether it's a bug or not, it's the way it always has
> been and always will be, so you just have to live with it.

Fair enough.

> The following is based on a great idea from Hartmut Figge in the
> SeaMonkey group; it makes it easy to tell whether there's a syntax
> error simply by looking at about:config.

That's what I did by inserting a dozen lines of the format:
user_pref("readthis.user.js", 1);
user_pref("readthis.user.js", 2);
user_pref("readthis.user.js", 3);
... and so on ...
user_pref("readthis.user.js", 12);

By sprinkling those lines about the file, and then testing what value the
readthis variable had, I could tell how far into the user.js file Firefox
got before aborting.

»Q«

unread,
Apr 14, 2016, 1:38:29 PM4/14/16
to mozilla-sup...@lists.mozilla.org
In
<news:mailman.282.1460640306...@lists.mozilla.org>,
Hans Donitz <hansd...@yahoo.com> wrote:

> »Q« wrote:

> > With hundreds of lines in your user.js, you definitely want syntax
> > highlighting in your editor
>
> I don't edit the user.js all that often.

Me either, but it only takes one edit to break everything. I assume
you make a backup before each edit. Edits of user.js are usually simple
enough to handle without the power of vi -- nano may be good enough,
and it has syntax highlighting.

I'll take one more shot at convincing you about syntax highlighting,
with screenshots:

<https://remarqs.org/misc/vim-jsfile.png>

<https://remarqs.org/misc/nano-jsfile.png>

> > The following is based on a great idea from Hartmut Figge in the
> > SeaMonkey group; it makes it easy to tell whether there's a syntax
> > error simply by looking at about:config.
>
> That's what I did by inserting a dozen lines of the format:
> user_pref("readthis.user.js", 1);
> user_pref("readthis.user.js", 2);
> user_pref("readthis.user.js", 3);
> ... and so on ...
> user_pref("readthis.user.js", 12);
>
> By sprinkling those lines about the file, and then testing what value
> the readthis variable had, I could tell how far into the user.js file
> Firefox got before aborting.

Ah, my eyes didn't catch that you had used the same pref name in all
those lines. I like starting the name with '00', to see it at a glance
at the top of the alpha-sorted about:config.



EE

unread,
Apr 14, 2016, 4:10:12 PM4/14/16
to mozilla-sup...@lists.mozilla.org
It could be that a line got an incorrect termination, or something like
that. I had a problem with my user.js file once. It looked perfectly
normal, but nothing past a certain line was copied into my settings. I
fixed it by rewriting some of the lines where I thought the problem was,
and that fixed it.

Jim Porter

unread,
Apr 14, 2016, 10:36:21 PM4/14/16
to mozilla-sup...@lists.mozilla.org
On 04/14/2016 01:29 AM, Hans Donitz wrote:
> Two questions:
> Q1: How (the heck) did you realize that?
> (I stared at it for a long while and didn't even notice that!)

I've seen the issue before with other cases of copy-and-pasting code. A
lot of webpages transform ASCII quotes to Unicode since they look prettier.

> Q2: Why would a unicode double quote cause the end of a user.js to occur?
> (Is that a bug?)

The bug is more likely in the site that you copied the original text
from; it shouldn't be transforming ASCII quotes to Unicode when the text
is actually program code.

Most programming languages are designed to use ASCII since Unicode is
really complex. Unicode is designed to handle every language out there,
and to say that there are a lot of different styles of quotation marks
is quite an understatement:
<https://en.wikipedia.org/wiki/Quotation_mark#Summary_table>.

- Jim

Hans Donitz

unread,
Apr 15, 2016, 12:17:46 AM4/15/16
to mozilla-sup...@lists.mozilla.org
Jim Porter wrote:

> I've seen the issue before with other cases of copy-and-pasting code. A
> lot of webpages transform ASCII quotes to Unicode since they look prettier.

Thanks Jim for noticing that.

You can't imagine how stupid I feel, knowing (now) that the answer was staring
me in the face all along.

> The bug is more likely in the site that you copied the original text
> from; it shouldn't be transforming ASCII quotes to Unicode when the text
> is actually program code.

I agree.

Almost certainly I copied the line (months ago?) and didn't even realize that
the user.js was stopping at that point!

(I feel even more stupid now.)

Hans Donitz

unread,
Apr 15, 2016, 12:30:35 AM4/15/16
to mozilla-sup...@lists.mozilla.org
»Q« wrote:

>> I don't edit the user.js all that often.
> I'll take one more shot at convincing you about syntax highlighting,
> with screenshots:

Those are pretty. And, I do know what syntax highlighting will do
as anyone who still uses "vi" is an old man (as you must be aware).

I learned vi before emacs became popular and my finger memory is
better than my real memory at this point (e.g., if you asked me
what command sequence I just ran in my last vi edit, I wouldn't
even know it - because my fingers do it, seemingly on their own).

>> user_pref("readthis.user.js", 1);
>> user_pref("readthis.user.js", 2);
>> user_pref("readthis.user.js", 3);

> I like starting the name with '00', to see it at a glance
> at the top of the alpha-sorted about:config.

I didn't realize the about:config results are alpha sorted, so,
I agree that it's a good idea to start the unique variable with
00.

Thanks for that tidbit. I need it right now because the ghacks
user.js is disabling the Firefox 43 "address bar" (not the search
bar) from doing searches (at least when Duckduckgo is the default
search engine).

http://www.ghacks.net/2015/08/18/a-comprehensive-list-of-firefox-privacy-and-security-settings/^M

So, I plan on inserting an illegal character in a made-up variable
so that I can easily truncate the file in various places, e.g.,
user_pref("00_findme.user.js", “); // note the illegal doublequotes

My plan to figure out *where* the Firefox address-bar search is being
disabled in the ghacks file is to do the following:

1. Edit the 1000-line user.js
$ vi user.js

2. Randomly sprinkle in a few dozen lines of the (illegal) format:
user_pref("00_findme.user.js", “); // note the illegal doublequotes

3. Test if the Firefox Address-Bar-Search is working yet.

4. If it's not working yet, I will delete the first illegal line
so that the user.js will be read to the second illegal line.

5. Then I'll test if the Firefox address-bar search is working yet.
If not, I delete the next illegal line, and so on.

At some point, I should be able to isolate where in the 1000-line
user.js the Firefox address-bar is being disabled.

Does that seem like a viable way to test without making dozens
of truncated user.js files?

PS: I already tested without a user.js and the Address-bar search
works just fine; so there's something in the ghacks user.js that
disables address-bar searching for some reason.

Hans Donitz

unread,
Apr 15, 2016, 12:31:59 AM4/15/16
to mozilla-sup...@lists.mozilla.org
EE wrote:

> It could be that a line got an incorrect termination, or something like
> that. I had a problem with my user.js file once. It looked perfectly
> normal, but nothing past a certain line was copied into my settings. I
> fixed it by rewriting some of the lines where I thought the problem was,
> and that fixed it.

Thanks for that advice.
That's sort of what the problem was.
Others (Jim Porter & Q) pointed out that I had accidentally copy-pasted
an illegal character in that the doublequotes were unicode (whatever that
means) when they're supposed to be ASCII.

Hans Donitz

unread,
Apr 15, 2016, 2:25:36 AM4/15/16
to mozilla-sup...@lists.mozilla.org
Hans Donitz wrote in message
mailman.346.1460694634...@lists.mozilla.org:

> At some point, I should be able to isolate where in the 1000-line
> user.js the Firefox address-bar is being disabled.

This is a neat approach to debugging long user.js files!

I used the illegal-character technique to find where the Firefox
address-bar search was being disabled!

Plus, I made the debugging test permanent!

Here's what I did just now:
0. I chose to use a unicode characters from Wikipedia that is obvious:
https://en.wikipedia.org/wiki/List_of_Unicode_characters

1. I sprinkled the user.js with this illegal line every 100 lines:
user_pref("00_stop.user.js", β); //illegal beta character stops user.js loading!

2. I typed the following into the URL bar (aka address bar) of Firefox:
?foo

3. If it worked (which it did until I got down to the 350th line),
I then killed Firefox and *commented out* the top-most illegal line
of the user.js that I had inserted, and repeated the process.

Once I got close, I sprinkled the illegal "beta" character every 25
lines. Soon, I ran into this line, which seems to be what was causing
the address bar to no longer act as a search engine:
user_pref("keyword.enabled", false);

I changed that line to:
user_pref("keyword.enabled", true);//false will disable url-bar search

And now the url-bar acts as a search engine again!
Voila!

NOTE: I have all "guessing" by Firefox turned off, so, the address
bar search is actually indistinguishable from the search-bar search
as the search bar never added any value whatsoever to Firefox (IMHO).

In addition, I have Firefox come up minimized to foil fingerprinting,
so, it's actually a pain to change the size of the Firefox window
just to be able to *see* the (normally useless) search bar.

NOTE: I left the test lines in the thousand-line user.js for future use.

Therefore, whenever I run about:config, *instantly* I know if the user.js
loaded to the end, because I would see a value of "10" in the first line
of output of about:config (thanks to Q's suggestion):

user_pref("00_canary.user.js", 100); <=== this is line 100 of user.js
user_pref("00_canary.user.js", 200); <=== this is line 200 of user.js
user_pref("00_canary.user.js", 300); <=== this is line 300 of user.js
... and so on ...
user_pref("00_canary.user.js", 1000); <=== this is the *last* line of user.js!

I also left the commented-out illegal-character lines so that at any time
I need to debug where in the thousand-line file a problem is occurring, I'm
already set up for testing!

//user_pref("00_stop.user.js", β); //illegal beta character stops user.js loading!

»Q«

unread,
Apr 15, 2016, 2:29:38 PM4/15/16
to mozilla-sup...@lists.mozilla.org
In
<news:mailman.346.1460694634...@lists.mozilla.org>,
Hans Donitz <hansd...@yahoo.com> wrote:

> »Q« wrote:

> I didn't realize the about:config results are alpha sorted, so,
> I agree that it's a good idea to start the unique variable with
> 00.

You can sort by any of the columns, by clicking the column header. I
just usually have mine sorted by the first column, ascending.

> Thanks for that tidbit. I need it right now because the ghacks
> user.js is disabling the Firefox 43 "address bar" (not the search
> bar) from doing searches (at least when Duckduckgo is the default
> search engine).
>
> http://www.ghacks.net/2015/08/18/a-comprehensive-list-of-firefox-privacy-and-security-settings/^M
>
> So, I plan on inserting an illegal character in a made-up variable
> so that I can easily truncate the file in various places, e.g.,
> user_pref("00_findme.user.js", “); // note the illegal doublequotes

That ghacks page causes people no end of headaches. Or maybe they're
all the same person, "protecting privacy" by posting with a different
name each time. (I keep a list of the names, in case the NSA ever
needs it. ;)

> Does that seem like a viable way to test without making dozens
> of truncated user.js files?

I guess so, but you've adopted a very time-consuming hobby. ;)

Ghacks' fairly comprehensive file full of footguns is pretty well
commented, including index numbers. I see downthread you found what
you wanted though iterative testing, but before I noticed that I found
it in a couple of seconds by loading
<http://www.ghacks.net/files/user.js%20[ghacks]-0.08-light.html> and
searching for "address bar" and "location bar". (I already knew the
pref name but tried to pretend I didn't.)

// 0801: disable location bar using search - PRIVACY
// don't leak typos to a search engine, give an error message instead
user_pref("keyword.enabled", false);

If I had a local copy, I'd probably have tried
'grep -iC 2 address.*bar footgun.js' and
'grep -iC 2 location.*bar footgun.js'

EE

unread,
Apr 15, 2016, 3:18:57 PM4/15/16
to mozilla-sup...@lists.mozilla.org
I realized that something was wrong because settings after a certain
group of settings in about:config had not been copied. I used a chrome
editor to rewrite some lines where I thought the problem must be, and
got tired after doing 14 lines, so decided to restart the application
and see if I had done enough to fix the problem. Everything was fine
after that, so I had indeed gotten the faulty line fixed.

Hans Donitz

unread,
Apr 16, 2016, 1:24:18 PM4/16/16
to mozilla-sup...@lists.mozilla.org
»Q« wrote in message
mailman.391.1460744975...@lists.mozilla.org:

> Ghacks' fairly comprehensive file full of footguns is pretty well
> commented, including index numbers. I see downthread you found what
> you wanted though iterative testing, but before I noticed that I found
> it in a couple of seconds by loading
> <http://www.ghacks.net/files/user.js%20[ghacks]-0.08-light.html> and
> searching for "address bar" and "location bar". (I already knew the
> pref name but tried to pretend I didn't.)

Thanks Q for that search advice, which would have saved me time
locating the errant setting in the ghacks file that was causing

I realized, only after the fact, that the ghacks comment mentioned
the address bar, but the actual setting was cryptic:
user_pref("keyword.enabled", true);//false will disable url-bar search

Searching the comments won't work all the time, but, I do agree
that grep'ping should work *much* of the time because the ghacks
file is reasonably well commented (which is why it's almost a
thousand lines long).

Still, it's a very nice technique to "truncate" a user.js file at
various locations simply by adding and then commenting out the
line as you suggested:

user_pref("00_stop.user.js", β); //illegal unicode beta character stops user.js loading at this point

At this point, I have my 'canary' lines every 100 lines, just in
case this happens again!
user_pref("00_canary.user.js", 100); <=== this is line 100 of user.js
user_pref("00_canary.user.js", 200); <=== this is line 200 of user.js
user_pref("00_canary.user.js", 300); <=== this is line 300 of user.js
... and so on ...
user_pref("00_canary.user.js", 1000); <=== this is the *last* line of user.js!

So, with these two "tricks", I'm all set to debug the *next* problem
that comes up with the user.js file.

Thanks for the two neat hints!
0 new messages