Why Do I Need Dropfox?

When you share a Firefox profile by Dropbox, you might not want to share a cache folder. But it is not easy. Let's see the case that you share a profile between Windows and Linux.

If you edit prefs.js. or user.js on Windows to change a cache folder from the default path to another one, the change is synchronized on Linux through Dropbox. When you start Firefox on Linux, the cache folder is forced to move to the default path because of the incompatibility of the path format between Windows and Linux. As a result, cache files of Linux side flow into the Windows side.

Of course, as well as this problem concerning cache folder, there would be many things which do not work as you expected.

Briefly, it is the problem that there is no mechanism which applies preferences, peculiar to an environment(an OS, a PC or a user), to a shared profile.

Dropfox provides the mechanism.


Dropfox enables you to use so to speak "extended user.js" which can include environment variables and regular Javascript codes. That enables you to change some preferences, such as a path of a cache folder or a path of an external editor so on, to new ones suitable for each OS environment such as Windows, Linux or Mac.

  • Allows you to have preferences files for each OS(Windows/Linux/Mac).
  • The format of the preferences file is basically same as prefs.js.
  • A value of preference can include environment variables in Unix-like format such as ${HOME}.
  • A value of preference can also include special folder variables, such as ${ProfD}, defined by Mozilla.
  • Also allows you to have a preferences file stored in an external folder of a profile folder for each OS.
  • You can include variables into the path of an external preferences file which you specify.
  • You can write regular Javascript codes in a preferences file.
  • You can write XPCOM codes in a preferences file.
  • You can execute commands of shells such as bash or PowerShell by using Dropfox API from Javascript codes.
  • A preferences file is loaded depending on the OS operating at the time of Firefox start, and executed.
  • Variables are converted at the time of execution.
  • Automatically removes conflicted files generated by Dropbox .

Format of Dropfox's Preferences File

You can write Javascript codes in a preferences file in the same format as prefs.js and can write variables in the second argument of user_pref() function.
See the following code.

user_pref("foo.boo.bar", "${HOME}/FOOBAR");

Of course you don't have to use a variable by all means.

The feature greatly different from prefs.js or user.js is that you can write Javascript codes other than "user_pref()" in them.

Shared Preferences File

The preferences files for each OSs are stored in a profile folder and are called "a shared preferences file" because they are shared with other machines by Dropbox. The shared preferences files are stored in the following path.


"WINNT" "Linux" "Darwin" is substituted for [OSName].

External Preferences File

Dropfox can execute the preferences files stored in an external folder of the profile folder. These files are called "an external preferences file". An external preferences file allows you to apply preferences peculiar to a machine for a shared profile. You can specify an external preferences file path which can include variables.


An external preferences file is loaded at the time of start of Firefox as well as a shared one, and is executed. Though the external preferences file format is the totally same as the shared one, note that you must save it in the UTF-8(without BOM) encoding.

Environment & Special Folder Variables

Dropfox allows you to include variables into preference values. You can use two kinds of variables in the same Unix-Like format like ${VariableName} integrally. The first is system environment variables such as ${HOME} or ${USERPROFILE} . They are defined by OS operating at the time. The second is special folder variables such as ${ProfD} or ${UChrm}. They are ones available in softwares using Mozilla technology. You can get more information about them from following URL.

File I/O - MDC

When there is a variable of the same name in both, note that a special folder variable is used.

Test Execution

There are two buttons labeled "TEST" in option window. If you push the button for shared preferences file, you can test the codes currently inputted in the text box. And if you push the button for external one, you can test the codes of external preferences file.

Dropfox Test Execution Result

You can confirm beforehand whether the result of conversion of variable is what you intended. But you must note that conversion of variables does depend on an execution environment. I recommend that you test in an actual environment.

Execution Order

Dropfox allow most general users to use 4 preferences files in Firefox. They are "prefs.js" and "user.js" and "shared preferences file" and "external preferences file". Their execution order is below.

prefs.js -> user.js -> shared prefs -> external prefs

The preference of prefs.js is a base. And it is overwritten with the following other three preferences files in turn. You should write preferences more peculiar to a machine in the later files.


Dropfox treat $ as a metacharacter in the second argument of "user_pref()" funcion. You can escape $ by writing $$. For example, when you want to treat "${HOME}" as a string not a variable, write as below

user_pref("foo.boo.bar", "$${HOME}");

You can confirm the result of escape in test execution beforehand.

Type of Value Converted from A Variable

Though you can include variables into preference value as string such as "${HOME}", some preferences need a specific value type. In this case, you can specify the type of value with three integers of the third argument. 0 means String type, 1 means Number type, and 2 means Boolean type.

See the following codes.

user_pref("foo.bar.myString","${MYSTRING}",0); //String
user_pref("foo.bar.myNumber","${MYNUMBER}",1); //Number
user_pref("foo.bar.myBoolean","${MYBOOLEAN}",2); //Boolean

In the case of String type, you don't need to specify because String type is default. 

Of course, when you specify the type as Number, the type of the value converted from variable must be a number. And when you specify the type as Boolean, the type of the value converted from variable must be "true" or "false".

You should confirm the result in test execution. If the new preference has been written with wrong type value, you must delete it manually. If the preference to which you are about to write a value with wrong type has already existed, an error only occurs.

Codes Other Than user_pref()

Dropfox is basically specialized to execute user_pref function, however it can also execute codes other than user_pref().

You can write regular Javascript codes such as a if sentence and also execute even XPCOM privilege codes. Dropfox's preferences file is programmable and  more flexible than user.js .


At the actual execution, codes are executed in the scope of "dropfox" which is a Object in a XPCOM-Context. "user_pref" function is executed as "dropfox.user_pref()".

At the test execution in option window, codes are executed in the scope of "dropfox" which is a Object in a Chrome-Window-Context.

Note that codes are executed in the defferent scope between actual execution and test execution.

You can access the actual execution scope from the test execution scope through "gDropfox.scope" Object in convenience for the time being. These specifications are temporary.

When Is Dropfox Executed?

Dropfox is executed when "profile-after-change" event is fired on Firefox start. The execution report window shows after "sessionstore- windows-restored" event.