How to compile Firefox extension (1)-technical preparation
I have been using Firefox for a long time. I like this little fox very much, especially the rich extensions it provides. I have always wanted to learn about the compilation of Firefox extensions. Now I can start. I will learn and write my own knowledge to help you learn.
I have collected some documents related to Firefox extensions. If the English is good enough, please view them directly and ignore my Article
Extension Development
Getting started with extension development
How to Write Firefox extensions using bugmenot as an Example
How to Create Firefox extensions
Writing an extension for Firefox
Firefox extension tutorial
Building an extension
The following are the technologies required to compile Firefox extensions.
When developing Firefox extensions, you will be exposed to the following technologies. You do not need to be proficient in these technologies, but you 'd better be familiar with them.
XUL (XML user-interface language). XML-based UI definition Technology
Javascript. You don't need to talk about this much. Most extensions use it to complete it.
Dom (Document Object Model). html document structure model.
XPCOM/xpconnect. the cross-platform component object model package provided by Mozilla can be used to access the preferences configuration database, filesystem file system, and other functions provided by Mozilla (javascript can be used, c ++, or even Python pyxpcom ).
CSS (Cascading Style Sheets ).
XBL (XML binding language). Used to expand XUL and allow creation of a new style UI.
RDF (Resource Description Framework). It is used to describe the storage format of some data in the extension ..
How to compile Firefox extension (2)-configure the development environment
To quickly and conveniently develop Firefox extensions, it is necessary to configure the development environment and make necessary preparations.
Configure Firefox
To avoid developing extended Firefox performance, we need to create a new configuration and name it "Dev ", use the following command line to start Firefox which is configured as the development environment.
Start "% ProgramFiles % \ Mozilla Firefox \ firefox.exe"-no-remote-P Dev
To run the default configuration, use "Firefox" or "Firefox-P default ".
You can also run the stable version and the developed firefox version to check the compatibility of the extended y (installing Firefox 3 or minefield while keeping Firefox 2 ).
Development Environment Configuration
The following configuration makes development, debugging, and expansion more convenient. View editing configuration files for more information. The following options are not displayed by default. About: it is listed in config, so you need to manually add them. You can find User. js If the file does not exist, create one manually and add the following lines:
User_pref ("nglayout. Debug. disable_xul_cache", true );
User_pref ("browser. Dom. Window. Dump. enabled", true );
Tip: In firefox3.0, user. js has been replaced by prefs. js.
Below are some available configuration options,
Javascript. Options. showinconsole = True . Record the error log to the error console.
Nglayout. Debug. disable_xul_cache = True . Disable XUL caching. In this way, you do not need to restart Firefox when modifying the interface elements. This option is only valid when you use the directory instead of the jar format to install the extension, and you still need to restart when modifying the XUL behavior.
Browser. Dom. Window. Dump. Enabled = True . Allow the dump () command to output information to the standard console see Window. Dump For more info. You can also use Nsiconsoleservice From privileged script.
Javascript. Options. Strict = True . Enables strict JavaScript warnings in the error console. note that since has people have this setting turned off when developing, you will see lots of warnings for problems with their code in addition to warnings for your own extension. you can filter those with console2.
Extensions. Logging. Enabled = True . This will send more detailed information about installation and update problems to the error console.
Some Firefox extensions used to assist in Firefox extension development
The name is a bit harsh, but it is definitely a good thing.
Dom inspector, an option of a custom installation.
Venkman, a javascript debugging tool.
Extension developer's extension development tool, which can be used to generate xpi files, set development options, and so on. It is strongly recommended.
Console2
Chrome list
Firebug JavaScript, HTTP debugging tool, powerful function, strongly recommended
Execute JS
Xpcomviewer, an XPCOM inspector
Custom Code Location
To avoid repeated extension installation after each code modification, you can put your source code under the Firefox configuration directory. Firefox will automatically detect and load your extension.
Find the extension number in install. RDF, such as EM: Id = "{46d1b3c0-db7a-4b1a-863a-6ee6f77ecb58 }"
Create a directory in the your_profile_directory/extensions/directory named the number you just found (eg. 'Your _ profile_directory/extensions/{region} ') (find your profile directory)
Copy your development file to this directory
Restart Firefox.