Go home
Notes
Introduction
- a Firefox extension can do many things:
- modify the Firefox user interface (menus, toolbars, tabs, etc.)
- perform actions on key press events or mouse click events
- change content on displayed web pages
- run compiled code written in C++ and linked with XPCOM
- this tutorial will give a description of how to write a simple extension, followed by a brief look at some of the different functionalities that an extension can provide (with examples)
Overview
- Building an Extension - general overview for how to build extensions
- create dev profile by running "firefox -P"
- create extension working directory with chrome.manifest and install.rdf
- update install.rdf by copy/paste and possibly changing information
- create sample.xul ("XUL Overlays" section)
- add the two lines to chrome.manifest
- create file in ~/.mozilla/firefox/[uid].dev/extensions with name of extension
- run Firefox as "MOZ_NO_REMOTE=1 firefox -P dev" and explain these options
- Extension documentation - _very good_ list of documents that describe different aspects of creating an extension
Interface components - XUL
- XUL Reference - documentation for available XUL elements
- Chrome URLs - chrome location of various standard elements
- /usr/share/firefox/chrome - where built-in chrome elements (in .xul files) are stored
- show how to figure out how the Find bar works
- Main Window: browser.jar/browser.xul
- initialization (.js include) near top and layout of Find bar near the bottom
- Find bar itself: toolkit.jar/findBar.js (included in browser.xul)
- demo Find bar unhiding on start; simple as adding the following inside the overlay tag:
<toolbar id="FindToolbar" hidden="false" />
- demo toolbar below Find bar with two buttons, one for changing status bar text (added earlier), one for hiding toolbar
User actions - Javascript
- XUL Periodic Table - XUL examples with inline Javascript
- create overlay command list ("hide" and "change") for "mainCommandSet" described in browser.xul
- add inline Javascript functions that implement hiding and label changing
- Keyboard Shortcuts - assigning key presses to functions in an extension
- add VK_F4 key press event for unhiding toolbar
- File I/O - how to read and write files from an extension
Packaging extensions
- use zip to create a .xpi file
- demonstrate installation through web page, command line
Example code
Further reading
- Building an Extension - links to several other resources, such as Preferences API, Chrome Command Line, Creating XPCOM Components, etc.
want to spend a vacation with your family? treat them like you've never done before, make then experience what is a real vacation place, then you might want to try this site.