Is it possible to create a conditional user_pref()
in Mozilla Firefox user.js?
I have tried using an if-else
statement, but the contents of the first if
statement is executed, even if the given condition is false
. The contents of the else
statement is ignored.
Example #1:
if ( false )
{
// This is executed even though the given condition is false in Mozilla Firefox user.js.
user_pref( 'browser.display.background_color', '#000000' );
}
else
{
// Unfortunately, this is not executed in Mozilla Firefox user.js.
user_pref( 'browser.display.background_color', '#FFFFFF' );
}
Additionally, I have also tried using a ternary
expression to conditionally change a user preference, but the expression is skipped entirely.
Example #2:
// This is not executed at all in Mozilla Firefox user.js.
user_pref( 'browser.display.background_color', ( 1 === 2 ? '#000000' : '#FFFFFF' ) );
Overall, I am trying to eventually find a way to change user_pref()
properties conditionally depending on the contents of window.location.href
.