Reputation: 6089
I am wondering how much power the user.js
preferences file gives to a user and how it works in greater detail
I tried to google search for that information but I couldnt find anything very descriptive.
From what I can see is that user.js is a javascript file that gets executed once when the browser starts and overrides all the preferences that were set prior.
What I am interested in is if you can use any logic that you could use in other javascript files.
Will simple if-else
statements get executed when placed in this file?
Is it able to use javascript functions that are available when executed in the browser (like setTimeout
)?
Can you use construction like in other js files; by that I mean writting your own functions and variables etc.
Or is the name js deceitful with no js functionality whatsoever?
Upvotes: 1
Views: 2255
Reputation: 13
I assume we can do something like this:
function disableAllTelemetry
{
user_pref(...);
user_pref(...);
user_pref(...);
...
}
I made a repo set up like this that has sections toggled by a handful of variables at the top of the file:
https://github.com/jeremy-neale/user.js
Since this isn't calling any other functions besides ones defined in the script, I assume something like this will work. Let me know if anyone discovers otherwise.
Not sure about using other built in javascript functions to do something like setTimeout
.
Upvotes: 0
Reputation: 35074
It just looks like a JavaScript file. Once upon a time in Netscape 3 and maybe 4 it actually was, but now it's just a file with a .js extension and a very restricted syntax that's parsed by a separate (non-JS) parser and not executed in any way.
Upvotes: 1
Reputation: 3153
From what I know, you can only call the pref() and *user_pref()* functions from user.js. I've tried to do some some conditional preferences based on the day of the week, but all the lines that didn't star with those functions were ignored.
At that time, I could not find any good documentation about the use of this file neither , but for my tests, the use of that file is limited to those two functions.
Very useful for System Administratos who can add customized user.js files via .XPI packages, but not for doing fancy stuff.
Upvotes: 1