スポンサーサイト
投稿日時 : -------- --:--
上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。
-------- --:-- | スポンサー広告
The Manual of Dropfox : Firefox Extension
投稿日時 : 2008-10-24 20:55
更新日時 : 2008-11-29 06:23
Visit following URL to get the latest information.
http://dropfox.no-ip.net/en/
 
日本語ページはこちら
 
This document is the translation version from Japanese to English.
The original one is here.
 
 
Dropfox Logo
 
Dropfox Screen Shot EN Dropfox Screenshot JP
 
Dropfox is the Firefox extension which manages preferences of a profile shared across different environments by Dropbox, and allows you to apply the preferences peculiar to each environment to the shared profile. You can change only some preference values such as the path of a cache folder to new ones suitable for each environment.
 

Main Features

  • 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 like ${HOME}.
  • A value of preference can also include special folder variables defined by Mozilla like ${ProfD}.
  • 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 Javascript codes other than "user_pref()" in a preferences file.
  • 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.
 
 

Installation

Dropfox :: Firefox Add-ons
 
 
 
The following article is a copy of the man page.
 
 

Why do I need Dropfox?

When you share a Firefox profile by Dropbox, you may not want to share a cache folder. But it is not easy. Let's see the scenario 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 the other 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, like this problem of cache folder, I think that there are many things which do not go well only by sharing merely preferences.

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

Dropfox offers the structure.


Features

When you share a profile across different environments with Dropbox, Dropfox allows you to change only some preference values such as the path of a cache folder to new ones suitable for each environment.

  • 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 like ${HOME}.
  • A value of preference can also include special folder variables defined by Mozilla like ${ProfD}.
  • 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 Javascript codes other than "user_pref()" in a preferences file.
  • 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.



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.

[YourProfileFolder]/dropfox.[OSName].js


"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.

${USERPROFILE}\MyExternalPref.js


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 and 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
https://developer.mozilla.org/index.php?title=File_I%2F%2FO

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.



Metacharacter

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 .



Scope

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.







スポンサーサイト
2008-10-24 20:55 | Dropfox English | Comment(0) | Trackback(0)
上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。