user_pref()
是否可以在 Mozilla Firefox user.js中创建条件?
我试过使用一个if-else
语句,但是第一个语句的内容if
被执行了,即使给定的条件是false
. else
语句的内容被忽略。
示例 #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' );
}
此外,我还尝试使用ternary
表达式有条件地更改用户首选项,但表达式被完全跳过。
示例 #2:
// This is not executed at all in Mozilla Firefox user.js.
user_pref( 'browser.display.background_color', ( 1 === 2 ? '#000000' : '#FFFFFF' ) );
总的来说,我试图最终找到一种方法来user_pref()
根据window.location.href
.