views:

1300

answers:

6

What the minimum basic setup required to begin developing a Firefox extension?

+13  A: 

Precaution: In order to prevent messing with your default firefox experience try the tip below on a newly created disposable test account.

Step 1: Create a new firefox profile. For this you need to invoke the Profile Manager via command line option: firefox.exe -profilemanager

Click on the 'Create Profile' button of the Profile Manager, which will invoke a wizard. Give the profile a name. Use the 'Choose Folder' button and save the profile in a appropriately named folder. This folder is where we are going to create our quick and dirty firefox extension.

Step 2: Change directory to 'extensions' folder within the profile folder created in Step 1. Now we need to give the firefox extension a globally unique name. Email like names are good enough for that. For example, [email protected] will be good enough name for the extension. Under the 'extensions' folder, create a folder with its name as the just chosen unique name.

Step 3: Create files chrome.manifest and install.rdf You can copy paste the sample here with the names, description altered appropriately.

chrome.manifest:

content 1mffext chrome/

and install.rdf:

<?xml version="1.0"?>
<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#"
         xmlns:NC="http://home.netscape.com/NC-rdf#"
         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;
  <RDF:Description RDF:about="rdf:#$Fsv+Z3"
                   em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
                   em:minVersion="2.0"
                   em:maxVersion="3.0.*" />
  <RDF:Description RDF:about="urn:mozilla:install-manifest"
                   em:id="[email protected]"
                   em:type="2"
                   em:name="[email protected]"
                   em:version="0.0.1"
                   em:description="One Minute FireFox extension"
                   em:creator="labsji "
                   em:homepageURL="http://labsji.wordpress.com"&gt;
    <em:contributor>Venkat83</em:contributor>
    <em:targetApplication RDF:resource="rdf:#$Fsv+Z3"/>
  </RDF:Description>

Step 4 Create folder called chrome and create a text file called test.txt within the folder. files in the folder will be accessible via chrome url like chrome://1mffext/content/test.txt

Now the bare minimum extension is ready. Regular html/javascript files can be used to create the functionality desired.

Testing the Extension: Invoke firefox to use the profile created above.

firefox.exe -profile <path of the newly created profile> -no-remote

I have created a googlecode project to share the resultant code created following the steps above. The code along with run scripts are available at Just a Minute Firefox Extension

Sim-OnDemand- personal virtual world as a Service's launcher application is an example of an application packaged and distributed using this method.

Balaji Sowmyanarayanan
much better. thank you.
Noah Goodrich
A: 

I suggest testing on the Portable edition of Firefox.

Osama ALASSIRY
It does not run in parallel with a normal Firefox, instead create an alternate profile to be able to run and restart a Firefox while keeping your regular Firefox open.
Jenko
But you can close the regular Firefox, and play with a portable one.
Osama ALASSIRY
+2  A: 

To start another instance of firefox with a different profile you can use the following command:

firefox -P My_test_profile -no-remote

This way you can have 2 different firefox running and use one for testing extensions without messing with the one you use regularly.

rogeriopvl
+1  A: 

Interesting information.
Now to answer the question, I would say: create a Greasemonkey script (or Chickenfoot, or iMacros, etc.).
Might be more limited (in changing FF UI for example) but good for most needs.

PhiLho
+1  A: 

Here are the reasons why someone would want to create a minimal firefox extension.

  1. When you wish to create a local computer( disk) resident browser based application, interacting with the file system for reading and writing is possible if the application is structured as an extension.
  2. Quick prototyping without worrying about XmlHttpRequest cross domain issues. When you run as plain application, user is hassled with a pop-up whenever XmlHttpRequest is attempted.
  3. Many a times, installing an extension causes a lot of angst in terms of 'Will this mess up with my other customizations?'. A work in progress extension can be distributed along with a profile so that the user can preview, test it. Without worrying about messing with the default firefox browsing experience.
Balaji Sowmyanarayanan
+7  A: 

Step 1: Use the Extension Wizard to generate all the necessary files.

Step 2: Extract the downloaded files into your development area.

Step 3: Create a text file in your profile's extensions folder named according to the em:id in the downloaded install.rdf file, put the full path to your extracted files in it then restart Firefox (delete the text file to uninstall if necesary).

robertc