為了改善您的使用體驗,本網站正在進行維護,部分功能暫時無法使用。若本站的文件無法解決您的問題,想要向社群發問的話,請到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

Is there a temporary equivalent of user.js?

  • 3 回覆
  • 0 有這個問題
  • 11 次檢視
  • 最近回覆由 cor-el

more options

Preferences in user.js are added permanently to prefs.js and persist even after user.js is deleted. What if you want to specify preferences in a file, just like with user.js, but you don't want them to be made permanent? In other words, so that when the file is deleted, the prefs will be forgotten. Is there any way to do this?

Preferences in user.js are added permanently to prefs.js and persist even after user.js is deleted. What if you want to specify preferences in a file, just like with user.js, but you don't want them to be made permanent? In other words, so that when the file is deleted, the prefs will be forgotten. Is there any way to do this?

所有回覆 (3)

more options

No, user.js is processed each time you launch Firefox and this means that changes you make only last in the current session. Changes from the default are stored prefs.js and you need to reset involved prefs on about:config or edit prefs.js to undo those changes.

A possible alternative is using an autoconfig.cfg file in the Firefox installation folder as that allows to redefine the default value (defaultPref(prefName, value)) what makes Firefox not store redefined value as this pref doesn't appear bold on about:config.

more options

Thanks for your reply, cor-el. I'm not sure if autoconfig offers a solution, though. If I put prefs into that file and then later delete that file, will those prefs persist? Or be lost? (I'm looking for a solution where the prefs would be lost after the prefs file is deleted.)

more options

If you want to disable autoconfig.cfg, then you need to remove or rename the "defaults\pref\autoconfig.js" file (remove the .js file extension as that is what matters) that specifies using autoconfig and not simply only remove autoconfig,cfg or you get an error when you start Firefox.

What I wrote above is to modify the default value of a pref and as long as you do not change this value from the default what makes it stored in prefs.js, then the pref will get its original default value if you disable autoconfig. If you make changes, then you keep those changes on following starts unlike with user.js that resets the pref to the value set via user.js. With autoconfig you can also do this if you use a pref() call pref(prefName, value) and not defaultPref() like you can read in the article. Autocofig works for all profiles as this file is stored in the installation folder.


You can use the autoconfig.cfg file in the Firefox installation folder to initialize (set/lock) preferences and run privileged JavaScript code.

To use Autoconfig, place two files into the Firefox installation directory.

  • on Windows, they go into the same directory where Firefox is installed
  • on macOS, they go into the Contents/Resources directory of the Firefox.app

The autoconfig.js file that specifies to use autoconfig.cfg is placed into the "defaults\pref" directory where the channel-prefs.js file is located. The autoconfig.cfg file is placed at the top level of the Firefox directory.

  • autoconfig.cfg and autoconfig.js need to start with a comment line (//)
  • autoconfig.js needs to use Unix line endings (LF instead of CR/LF), so use an editor like Notepad++ that can handle this

See also:


Content of autoconfig.js:

// start autoconfig.js with a comment line 
pref("general.config.filename", "autoconfig.cfg");
pref("general.config.obscure_value", 0);

Content of autoconfig.cfg:

// start autoconfig.cfg with a comment line