Add-ons provide new features for Gecko-based applications such as Firefox, SeaMonkey, and Thunderbird. There are two main types of add-ons: Extensions (which can be added to the application), themes (changes to the appearance of the application)
1. Add-ons have three different ways to create extensions:
- Based on the add-on SDK approach (use a high-level set of JavaScript APIs to develop extensions that do not require a restart.) Recommended Use )
- No need to restart the extension (manually create an extension without rebooting)
- Traditional way (traditional extensions are created using overly methods)
2. Based on the add-on SDK, the required configuration:
- Python 2.5,2.6 or 2.7. Make sure you've installed Python.
- Firefox firefox browser (this tutorial is for the latest browser).
- SDK itself: You can get the latest stable version of the SDK as a Tarball compressed package or zip file .
3.add-on SDK for each platform installation:
[1]. Mac OS X:
Use the following command to install the SDK Plugin tool via homebrew
Brew Install MOZILLA-ADDON-SDK
[2]. Mac OS X/linux:
whichever way you choose to get the Tarball compressed package or zip file, unzip it as the root path and switch to the root directory of the SDK by shell/command prompt
TAR-XF ADDON-SDK.TAR.GZCD Addon-sdk#bash User (majority Yes) source bin/activate# non-bash user #bash bin/activate
When the above command finishes running, you see the following results
[3]. Windows:
Run directly after download decompression
Bin\activate
The operating environment of the SDK is built on each platform through the above operation.
4. Making the Startup item
Windows: Use the Bin\activate\activate.bat batch script script, or use the command line setx tool or Control Panel to activate permanent use.
Mac OS x/linux:bin\activate\activate bash script, you can also /bin create a symbolic link to the CFX program in the directory
Ln-s Your SDK directory/BIN/CFX/BIN/CFX
In the Command window, enter CFX, check the
For example, the SDK is perfectly perfect.
5. Install NPM
- Download node. js, and install it.
- Add path/USR/LOCAL/BIN/NPM to system variable $path
echo "Export path=/usr/local/bin/npm: $PATH" >> ~/.bash_profile
6. Installing JPM
Execute the following command
sudo npm install JPM--global
Hold on a moment.
At this point all the SDKs, commands are all done, immediately to get an add-ons to play.
7. A quick-start initialization of an empty extension
1. Initialize, create a new folder in the Command Line window. Enter the newly created folder, finally CFX init, enter
mkdir MY-ADDONCD MY-ADDONCFX Init
The following information appears
2. To implement the extension, open the "main.js" file in the "Lib" folder created in the previous step and add the following code
var buttons = require (' sdk/ui/button/action '), var tabs = require ("Sdk/tabs"), var button = buttons. Actionbutton ({ ID: "Mozilla-link", Label: "Visit Mozilla", icon: { "+": "./icon-16.png", "32": "./icon-32.png", "+": "./icon-64.png" }, Onclick:handleclick}); function Handleclick (state) { Tabs.open ("http://www.mozilla.org/");}
3. Save the following three icon files to the "Data" folder
4. Go back to the command line window and execute the command
CFX Run
Automatically open Firefox and click on the Firefox icon in the toolbar to jump to the Firefox homepage (http://www.mozilla.org/)
5. Packaging accessory components, executing commands
CFX XPI
Get the following information, generate the My-addon.xpi file under My-addon,
In the Firefox File menu, choose the Open menu item. A File Selection dialog box appears: Locate the "my-addon.xpi" file, open it and follow the prompts that appear to install it.
8. Review
In this tutorial, we used three commands to create and package an extension:
cfx initInitialize an empty extension template
cfx runRun a new Firefox instance with the extension installed so that we can try to extend
cfx xpiPackage extension to a XPI file for publishing
This site article is for baby bus SD. Team Original, reproduced must be clearly noted: (the author's official website: Baby bus )
Reprinted from "Baby bus Superdo Team" original link: http://www.cnblogs.com/superdo/p/4801079.html
[firefox_ add-ons]_001_ Getting Started