1
Customize the InterfaceAlmost all of Firefox's interface is
customizable, but for starters, here's a simple context-menu add-on that looks
up selected text on Wikipedia. Edit the XUL file to change the appearance of
your extension: Menu text goes in the label attribute; the accesskey is the
keyboard shortcut, which will be underlined in the menu;
insertafter
indicates position in the context menu; the name of your JavaScript function
goes in the
oncommand attribute; and the filename of your JS file goes in
the <script src> tag.
2 Add
Some ActionThe JavaScript code you include in your JS file defines the
behavior of your extension. Here, the
lookuponwikipedia() function (run
by the XUL file) glues together the Wikipedia URL with the selected text and
then opens the resulting URL in a new window. What will your extension do? See
developer.mozilla.org/en/docs/JavaScript if you need some basic
programming help.
3 Take
StockUpdate the two
Contents.rdf files by replacing all the
occurrences of
wikipedialookup with the name of your extension. Make sure
that the
Contents.rdf file in the content folder correctly points to the
filename of your XUL file. When you're done, rename the ZIP archive (the one
containing the skin and content folders) with a
.jar extension.
4
Update the Install ScriptThere are six lines to update in the
Install.rdf file: the name of your extension, the version number, the
creator (you), a brief description, the name of the
.jar file, and a
unique ID that differentiates your extension from all others. Update the
Install.js file in the same way so your extension will also install on
SeaMonkey, Mozilla Suite, and Netscape.
5 Put
It Back TogetherWith all the files updated, rename the main ZIP file
with an
.xpi extension again. Make sure that the directory structure
exactly matches the example XPI. To install your extension, drag and drop your
XPI file onto an open Firefox window, and then restart Firefox.
6 Check
Your Work
Test your extension on a real Web site. If you get an error, or
if something doesn't work, retrace your steps and see if you missed anything. If
you want to share your extension with others, or to get help or see other
examples, visit developer.mozilla.org/en/docs/Extensions
Save Your Extensions
Found a Firefox extension you can't live without?
Don't risk your favorites not being around the next time you upgrade your PC or
reinstall Microsoft Windows. Right-click any Install Now link at
addons.mozilla.org, and select Save Link As to store a copy of the XPI
installer someplace safe. Or use another extension—FEBE, which backs up your
extensions, themes, and more.
The Web Your Way Don't have the time to package and test a full-blown
extension? Greasemonkey,
possibly the most powerful of all Firefox extensions, lets you customize your
favorite Web sites with bits of JavaScript. Add features, remove unwanted
content, or even fix bugs: Write the scripts yourself or download them from
userscripts.org.
From:PC MAGZINE