Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Create a Quick Minimal Firefox Extension?

Tags:

firefox

xul

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

like image 804
Balaji Sowmyanarayanan Avatar asked Nov 08 '08 11:11

Balaji Sowmyanarayanan


People also ask

How do I make Firefox minimal?

Click More tools. Choose Customize toolbar…. At the bottom of the panel, click Density. Choose Compact (not supported) from the menu options.

How do I pack Firefox extensions?

In Firefox: Open the about:debugging page, click the This Firefox option, click the Load Temporary Add-on button, then select any file in your extension's directory. The extension now installs, and remains installed until you restart Firefox.


1 Answers

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

like image 69
Balaji Sowmyanarayanan Avatar answered Oct 28 '22 01:10

Balaji Sowmyanarayanan