Changes

Jump to: navigation, search

Dive into Mozilla Modifying Firefox using an Extension Lab

1,317 bytes added, 15:16, 14 March 2007
Extension files and directory structure
chrome/
content/
Because this is a first extension, we will skip some [http://developer.mozilla.org/en/docs/Building_an_Extension#Setting_up_the_Development_Environment other directories and files] that more complete extensions would include (e.g., localization, skins).
====addtabbeside/====
Having added our script and overlay files, we now need to add a couple of meta data metadata files to help Firefox understand and install/load our extension. 
Here The first is the '''addtabbeside/content.manifest''' , which is a [http://developer.mozilla.org/en/docs/Chrome_Manifest Chrome Manifest]. This filehelps Firefox translate between chrome:// URIs and actual files on disk. It also allows us to specify where our overlay will be merged into the browser:
# Chrome package '''addtabbeside''' has it's '''content''' in ./chrome/content
content addtabbeside chrome/content/
# Overlay the '''overlay.xul''' file with '''browser.xul'''
overlay chrome://browser/content/browser.xul chrome://addtabbeside/content/overlay.xul
The first line registers the location for our content (i.e., .xul, .js). The second line registers our overlay, and says that overlay.xul will be merged with browser.xul. Mozilla uses chrome:// URIs to refer to aspects of the interface, and chrome://browser/content/browser.xul ''is'' the browser (try typing it into the address bar).
    chrome:The second metadata file we need to create is '''addtabbeside//browser/content/browserinstall.xul               Start by creating a new extension, either by hand, or using Ted Mielczarekrdf'''s wonderful wizard:  . This is an [http://teddeveloper.mielczarekmozilla.org/codeen/mozilladocs/extensionwiz/       Here is Install_Manifests install manifest] that tells the '''Firefox addon manager how to install.rdf''' file for the extension:, with information like who wrote it, the version number, compatibility information, etc.
<pre>
<?xml version="1.0" encoding="UTF-8"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>addtabbeside@senecac.on.ca</em:id>
<em:creator>David Humphrey</em:creator>
<em:description>New tabs are created beside the current tab instead of at the end of the tab list.</em:description>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!-- firefox -->
</Description>
</em:targetApplication>
</Description>
</RDF>
</pre>
===Testing the extension===
Eventually we'll package our extension properly into a redistributable .xpi. However, while we're testing it's nice to be able to use it in an expanded state so we can make changes.
To this end, create a file named '''addtabbeside@senecac.on.ca''' and put it in your development profile's extensions directory (NOTE: replace ''Username'' with your username and ''dev-profile'' with your development profile name):
C:\Documents and Settings\''Username''\Application Data\Mozilla\Firefox\Profiles\''dev-profile''\extensions\addtabbeside@senecac.on.ca
 Create a file named: '''addtabbeside@senecac.on.ca''' This file should contain the a single line of text--the full path to your extension, for example:
C:\temp\addtabbeside
Now put this file in Start your development profilebrowser and make sure your extension is loaded (check 's extensions directory (NOTE: replace ''UsernameTools > Add-ons'' with your username ') and working properly by creating some tabs to see where they get positioned. If you're having problems, check the ''dev-profile'Error Console' with your development profile name):  C:\Documents and Settings\''Username(''\Application Data\Mozilla\Firefox\Profiles\'Tools > Error Console'dev-profile''\extensions) for hints.
==First Attempt==

Navigation menu