Chapter 1: Introduction to Extensions

  • Revision slug: Firefox_addons_developer_guide/Introduction_to_Extensions
  • Revision title: Chapter 1: Introduction to Extensions
  • Revision id: 97813
  • Created:
  • Creator: Lebedel.delphine
  • Is current revision? No
  • Comment 2 words added, 2 words removed

Revision Content

{{ Fx_minversion_header("3") }} {{ Draft() }}

{{template.PreviousNext("En/Firefox addons developer guide", "En/Firefox addons developer guide/Chapter 2: Technologies used in developing extensions")}}

This document was authored by Hideyuki Emura and was originally published in Japanese for the Firefox Developers Conference Summer 2007. Emura-san is a co-author of Firefox 3 Hacks (O'Reilly Japan, 2008.)

Introduction

If you’re reading this guide, you’ve probably used Firefox before. Perhaps the first time you looked at Firefox, you may have been surprised to see that it has a much simpler structure than other full-featured browsers, such as Opera or Safari.

What features are considered de rigueur for web browsers these days? Perhaps things like fine-grained tab controls, mouse gestures, extensive toolbars and buttons, a feed reader, integration with a variety of web applications, or sophisticated tools to assist with web design. But we did not set out to create an all-in-one browser that can satisfy everyone.

Instead, Firefox can support these features through extensions. The core browser is limited to basic features, so it’s something that a beginner can be comfortable with, but users who want something beyond that can install extensions.

About extensions

Management using the Add-on Manager

Firefox’s Add-on Manager is an excellent way to manage extensions, and is a great step up in ease of use.

Addons manager.png

 

  • Performs installs and uninstalls safely;
  • Checks compatibility between Firefox and extensions;
  • Manages whitelist of installation sites;
  • Troubleshoots extensions using initial disabling and safe-mode;
  • Confirms and runs updates;
  • Provides access to settings dialogs;
  • Provides access to support site.

Development-environment amenities

Initially, there wasn’t even adequate documentation available, and extension developers were largely left to fend for themselves1; by now, they’ve acquired a considerable store of knowledge.

Because Firefox and its extensions are designed to support multiple languages, excellent extensions come from all over the world, and can be quickly localized by anyone interested.

This lowers the threshold both to using and to developing extensions, and that fact, combined with Firefox’s rapidly growing popularity, has created a positive feedback loop, with the number of extension users and extension developers growing explosively—there are now more than 5000 extensions and themes published at the Firefox Add-ons site (https://addons.mozilla.org).

What you can do with extensions

Let’s look at what features extensions can add, and some actual examples of extensions.

Single-feature extensions

These are relatively simple extensions that add a single feature.

Text Link
https://addons.mozilla.org/firefox/1939/
Makes it so that double-clinking on an unlinked URL follows that URL.
Undo Closed Tabs Button
https://addons.mozilla.org/firefox/3082/
Adds a toolbar button to re-open the most recently closed tabs to the History menu

{{ TODO("Screenshot: Undo Closed Tabs Button, which adds a button to the toolbar") }}

Locationbar
https://addons.mozilla.org/firefox/4014/
Separates a URL’s domain and path in the location bar for easier reading {{ TODO("Screenshot: Locationbar, which makes the URL more legible") }}.

Feature-enhancing extensions

These extensions enhance features that already exist in Firefox.

Tab Mix Plus
https://addons.mozilla.org/firefox/1122/
Offers detailed tab-related settings.
PrefBar
http://prefbar.mozdev.org
Gives access to numerous preferences from the toolbar {{ TODO("Screenshot: Prefbar, which adds its own special toolbar") }}.
Noscript
https://addons.mozilla.org/firefox/722/
Permits JavaScript execution on a site-by-site basis.

Web-application integration extensions

The use the APIs of certain web applications to provide certain pieces of information.

GmailManager
https://addons.mozilla.org/firefox/1320/
Displays number of messages received in the status bar.
Adsense Notifier
https://addons.mozilla.org/firefox/500/
Displays Adsense revenue in status bar.
Forecastfox
https://addons.mozilla.org/firefox/398/
Displays weather forecast in status bar {{ TODO("Screenshot: Forecastfox, which displays weather information in the status bar.") }}.

New-feature extensions

Extensions can add completely new features to Firefox. This class of extension requires a greater level of knowledge and programming ability.

Greasemonkey
https://addons.mozilla.org/firefox/748/
UserChrome.js
http://forums.mozillazine.org/viewtopic.php?t=397735

Both of these provide an environment for running user scripts (JavaScript) in Firefox itself,
where the scripts can target specific websites.

Adblock Plus
https://addons.mozilla.org/firefox/1865/
Blocks the display of unwanted advertisements on web pages.
All-in-One Gestures
https://addons.mozilla.org/firefox/12/
Adds mouse-gesture functionality.

Application-level extensions

These are sophisticated extensions that can be considered full-scale applications in their own right, essentially using Firefox as the development platform.

Sage
https://addons.mozilla.org/firefox/77/
An advanced RSS reader.
Scrapbook
https://addons.mozilla.org/firefox/427/
A web-page scrapbook organizer.
Firebug
https://addons.mozilla.org/firefox/1843/
An extremely sophisticated web-development environment for inspecting and debugging CSS,
HTML, and JavaScript {{ TODO("Screenshot: Firebug, an advanced web debugging environment") }}.

One-trick gag extensions

There are a number of one-trick gag extensions that aren’t very useful.

Together with Foxkeh
https://addons.mozilla.org/firefox/3867/
Displays Foxkeh, the mascot of Mozilla Japan, in the sidebar and in dialogs.
Turn Cancel button into a shiitake mushroom
https://addons.mozilla.org/firefox/4298
Like it says on the tin, turns the Cancel button into the cap of a shiitake mushroom{{ TODO("Screenshot: The Cancel button as a shiitake mushroom") }}.

This is a very brief survey of a few extensions , but there are many other unique extensions available.

Table 1: Advanced customization methods for Firefox

{{ TODO("Make the table cleaner") }}

  Web page Firefox itself
User style sheets (change appearance through CSS)

Yes

userContent.css

Stylish

Yes

userChrome.css

Stylish

User scripts (change appearance and functionality through JavaScript)

 

Yes

Greasemonkey

bookmarklets

Yes

userChrome.js

Extensions (anything can do) Yes Yes
Theming (change appearance) No Yes

Let’s build an extension

Table 1 shows the various customization options available to a user in Firefox. Users have flexible customization options, using CSS in user style sheets and JavaScript/DOM in user scripts (these depend on Stylish, Greasemonkey, and userChrome.js).

In addition to CSS and JavaScript, extensions can take advantage of XUL and XPCOM technologies for more sophisticated features. Themes, which alter Firefox’s appearance, are a special kind of extension.

In order to create an extension, you need an idea and just a little programming ability. The following chapters explain in detail the extension-writing techniques of some of Japan’s leading extension authors. We encourage you to try your hand as well.

1 One of the authors of this special edition, Piro, is world-famous as one of the original developers.

 

Revision Source

<p style="text-align: justify;"><font size="3"><font color="#000000">{{ Fx_minversion_header("3") }} {{ Draft() }}</font></font></p>
<p style="text-align: justify;"><font size="3"><font color="#000000">{{template.PreviousNext("En/Firefox addons developer guide", "En/Firefox</font></font><font size="3"><font color="#000000"> addons developer guide</font></font><font size="3"><font color="#000000">/Chapter 2: Technologies used in developing extensions")}}</font></font></p>
<p><em>This document was authored by </em><a class="external" href="http://level.s69.xrea.com/mozilla/" title="http://level.s69.xrea.com/mozilla/"><em>Hideyuki Emura</em></a><em> and was originally published in Japanese for the </em><a class="link-https" href="https://wiki.mozilla.org/Japan/FxDevCon/Summer2007/English" title="https://wiki.mozilla.org/Japan/FxDevCon/Summer2007/English"><em>Firefox Developers Conference Summer 2007</em></a><em>. Emura-san is a co-author of <a class="external" href="http://www.oreilly.co.jp/books/9784873113753/index.html" title="http://www.oreilly.co.jp/books/9784873113753/index.html">Firefox 3 Hacks</a> (O'Reilly Japan, 2008.)<br>
</em></p>
<h2>Introduction</h2>
<p>If you’re reading this guide, you’ve probably used Firefox before. Perhaps the first time you looked at Firefox, you may have been surprised to see that it has a much simpler structure than other full-featured browsers, such as Opera or Safari.</p>
<p>What features are considered de rigueur for web browsers these days? Perhaps things like fine-grained tab controls, mouse gestures, extensive toolbars and buttons, a feed reader, integration with a variety of web applications, or sophisticated tools to assist with web design. But we did not set out to create an all-in-one browser that can satisfy everyone.</p>
<p>Instead, Firefox can support these features through extensions. The core browser is limited to basic features, so it’s something that a beginner can be comfortable with, but users who want something beyond that can install extensions.</p>
<h2>About extensions</h2>
<h3>Management using the Add-on Manager</h3>
<p>Firefox’s Add-on Manager is an excellent way to manage extensions, and is a great step up in ease of use.</p>
<p><img alt="Addons manager.png" class="internal default" src="/@api/deki/files/3290/=Addons%20manager.png" style="width: 520px; height: 380px;"></p>
<p> </p>
<ul> <li>Performs installs and uninstalls safely;</li> <li>Checks compatibility between Firefox and extensions;</li> <li>Manages whitelist of installation sites;</li> <li>Troubleshoots extensions using initial disabling and safe-mode;</li> <li>Confirms and runs updates;</li> <li>Provides access to settings dialogs;</li> <li>Provides access to support site.</li>
</ul>
<h3>Development-environment amenities</h3>
<p>Initially, there wasn’t even adequate documentation available, and extension developers were largely left to fend for themselves<sup><a href="#footnote1" id="from_footnote1">1</a></sup>; by now, they’ve acquired a considerable store of knowledge.</p>
<p>Because Firefox and its extensions are designed to support multiple languages, excellent extensions come from all over the world, and can be quickly localized by anyone interested.</p>
<p>This lowers the threshold both to using and to developing extensions, and that fact, combined with Firefox’s rapidly growing popularity, has created a positive feedback loop, with the number of extension users and extension developers growing explosively—there are now more than 5000 extensions and themes published at the Firefox Add-ons site (<a class=" link-https" href="https://addons.mozilla.org" rel="freelink">https://addons.mozilla.org</a>).</p>
<h2>What you can do with extensions</h2>
<p>Let’s look at what features extensions can add, and some actual examples of extensions.</p>
<h3>Single-feature extensions</h3>
<p>These are relatively simple extensions that add a single feature.</p>
<dl> <dt>Text Link</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/1939/" rel="freelink">https://addons.mozilla.org/firefox/1939/</a></dd> <dd>Makes it so that double-clinking on an unlinked URL follows that URL.</dd> <dt>Undo Closed Tabs Button</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/3082/" rel="freelink">https://addons.mozilla.org/firefox/3082/</a></dd> <dd>Adds a toolbar button to re-open the most recently closed tabs to the History menu</dd> </dl>
<p>{{ TODO("Screenshot: Undo Closed Tabs Button, which adds a button to the toolbar") }}</p>
<dl><dt>Locationbar</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/4014/" rel="freelink">https://addons.mozilla.org/firefox/4014/</a></dd> <dd>Separates a URL’s domain and path in the location bar for easier reading {{ TODO("Screenshot: Locationbar, which makes the URL more legible") }}.</dd>
<h3>Feature-enhancing extensions</h3>
<p>These extensions enhance features that already exist in Firefox.</p>
<dl><dt>Tab Mix Plus</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/1122/" rel="freelink">https://addons.mozilla.org/firefox/1122/</a></dd> <dd>Offers detailed tab-related settings.</dd> <dt>PrefBar</dt> <dd><a class=" external" href="http://prefbar.mozdev.org" rel="freelink">http://prefbar.mozdev.org</a></dd> <dd>Gives access to numerous preferences from the toolbar {{ TODO("Screenshot: Prefbar, which adds its own special toolbar") }}.</dd> <dt>Noscript</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/722/" rel="freelink">https://addons.mozilla.org/firefox/722/</a></dd> <dd>Permits JavaScript execution on a site-by-site basis.</dd> </dl>
<h3>Web-application integration extensions</h3>
<p>The use the APIs of certain web applications to provide certain pieces of information.</p>
<dl> <dt>GmailManager</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/1320/" rel="freelink">https://addons.mozilla.org/firefox/1320/</a></dd> <dd>Displays number of messages received in the status bar.</dd> <dt>Adsense Notifier</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/500/" rel="freelink">https://addons.mozilla.org/firefox/500/</a></dd> <dd>Displays Adsense revenue in status bar.</dd> <dt>Forecastfox</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/398/" rel="freelink">https://addons.mozilla.org/firefox/398/</a></dd> <dd>Displays weather forecast in status bar {{ TODO("Screenshot: Forecastfox, which displays weather information in the status bar.") }}.</dd></dl>
<h3>New-feature extensions</h3>
<p>Extensions can add completely new features to Firefox. This class of extension requires a greater level of knowledge and programming ability.</p>
<dl> <dt>Greasemonkey</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/748/" rel="freelink">https://addons.mozilla.org/firefox/748/</a></dd> <dt>UserChrome.js</dt> <dd><a class=" external" href="http://forums.mozillazine.org/viewtopic.php?t=397735" rel="freelink">http://forums.mozillazine.org/viewtopic.php?t=397735</a></dd></dl>
<p>Both of these provide an environment for running user scripts (JavaScript) in Firefox itself,<br>
where the scripts can target specific websites.</p>
<dl> <dt>Adblock Plus</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/1865/" rel="freelink">https://addons.mozilla.org/firefox/1865/</a></dd> <dd>Blocks the display of unwanted advertisements on web pages.</dd> <dt>All-in-One Gestures</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/12/" rel="freelink">https://addons.mozilla.org/firefox/12/</a></dd> <dd>Adds mouse-gesture functionality.</dd></dl>
<h3>Application-level extensions</h3>
<p>These are sophisticated extensions that can be considered full-scale applications in their own right, essentially using Firefox as the development platform.</p>
<dl> <dt>Sage</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/77/" rel="freelink">https://addons.mozilla.org/firefox/77/</a></dd> <dd>An advanced RSS reader.</dd> <dt>Scrapbook</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/427/" rel="freelink">https://addons.mozilla.org/firefox/427/</a></dd> <dd>A web-page scrapbook organizer.</dd> <dt>Firebug</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/1843/" rel="freelink">https://addons.mozilla.org/firefox/1843/</a></dd> <dd>An extremely sophisticated web-development environment for inspecting and debugging CSS,<br>
HTML, and JavaScript {{ TODO("Screenshot: Firebug, an advanced web debugging environment") }}.</dd></dl>
<h3>One-trick gag extensions</h3>
<p>There are a number of one-trick gag extensions that aren’t very useful.</p>
<dl> <dt>Together with Foxkeh</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/3867/" rel="freelink">https://addons.mozilla.org/firefox/3867/</a></dd> <dd>Displays Foxkeh, the mascot of Mozilla Japan, in the sidebar and in dialogs.</dd> <dt>Turn Cancel button into a shiitake mushroom</dt> <dd><a class=" link-https" href="https://addons.mozilla.org/firefox/4298" rel="freelink">https://addons.mozilla.org/firefox/4298</a></dd> <dd>Like it says on the tin, turns the Cancel button into the cap of a shiitake mushroom{{ TODO("Screenshot: The Cancel button as a shiitake mushroom") }}.</dd></dl>
<p>This is a very brief survey of a few extensions , but there are many other unique extensions available.</p>
<p>Table 1: Advanced customization methods for Firefox</p>
<p>{{ TODO("Make the table cleaner") }}</p>
<table align="center" border="1" cellpadding="1" cellspacing="1" width="200"> <tbody> <tr> <td> </td> <td>Web page</td> <td>Firefox itself</td> </tr> <tr> <td>User style sheets (change appearance through CSS)</td> <td> <p>Yes</p> <p>userContent.css</p> <p>Stylish</p> </td> <td> <p>Yes</p> <p>userChrome.css</p> <p>Stylish</p> </td> </tr> <tr> <td>User scripts (change appearance and functionality through JavaScript)</td> <td> <p> </p> <p>Yes</p> <p>Greasemonkey</p> <p>bookmarklets</p> </td> <td> <p>Yes</p> <p>userChrome.js</p> </td> </tr> <tr> <td>Extensions (anything can do)</td> <td>Yes</td> <td>Yes</td> </tr> <tr> <td>Theming (change appearance)</td> <td>No</td> <td>Yes</td> </tr> </tbody>
</table>
<h2>Let’s build an extension</h2>
<p>Table 1 shows the various customization options available to a user in Firefox. Users have flexible customization options, using CSS in user style sheets and JavaScript/DOM in user scripts (these depend on Stylish, Greasemonkey, and userChrome.js).</p>
<p>In addition to CSS and JavaScript, extensions can take advantage of XUL and XPCOM technologies for more sophisticated features. Themes, which alter Firefox’s appearance, are a special kind of extension.</p>
<p>In order to create an extension, you need an idea and just a little programming ability. The following chapters explain in detail the extension-writing techniques of some of Japan’s leading extension authors. We encourage you to try your hand as well.</p>
<div class="footnotes">
<div class="note" id="footnote1"><a href="#from_footnote1">1</a> One of the authors of this special edition, Piro, is world-famous as one of the original developers.</div>
</div>
</dl>
<p> </p>
Revert to this revision