How To Write Your First Firefox Extension

Robert Nyman
Robert NymanGlobal Lead for Programs & Initiatives, Web Developer Relations
How to Write Your
 First Extension
How To Write Your First Firefox Extension
Bruce Willis Extension
         (Francois Mori/AP Photo)
How to Write Your First Extension

1. Create development profile
2. Configuration settings
3. Pointing extension to your dev directory
4. Creating folder structure & files
5. Packaging & installing
6. Distributing your add-on
Create Development
       Profile
Keep a separate Firefox profile for
     extension development
Windows:
Start menu > Run (Windows key + R).
Write firefox -P and press click OK.

Mac OS X (in Terminal):
Type in /Applications/Firefox.app/
Contents/MacOS/firefox -
profilemanager


Linux (in a terminal):
Use cd to navigate to your Firefox directory and
then enter ./firefox -profilemanager
How To Write Your First Firefox Extension
How To Write Your First Firefox Extension
How To Write Your First Firefox Extension
Pointing Extension to
 Your Development
      Directory
Find your Profile directory
Windows:

Win XP: C:Documents and Settings[user name]
Application DataMozillaFirefoxProfiles

Vista: C:Users[user   name]AppDataRoaming


Mac OS X (~ = /Users/[user      name]):

~/Library/Application Support/Firefox/Profiles/


Linux:

~/.mozilla/
Go to [Dev Profile]/extensions/ folder
Create empty file (no file extension!):

brucewillis@robertnyman.com
How To Write Your First Firefox Extension
Point to your extension code, i.e. file path:


Windows:

E.g: C:devbrucewillis

Mac/Linux:

E.g: ~/dev/brucewillis/
Configuration Settings
1. Open Firefox:

  - Have your development profile as default
  - or Through Profile Manager

2. Type in about:config
How To Write Your First Firefox Extension
Recommended settings:

javascript.options.showInConsole = true

nglayout.debug.disable_xul_cache = true

browser.dom.window.dump.enabled = true
• Optional settings:
  javascript.options.strict = true

  extensions.logging.enabled = true
How To Write Your First Firefox Extension
How To Write Your First Firefox Extension
Creating Folder
Structure & Files
How To Write Your First Firefox Extension
• Automatic creation of extension
• Extension Developer extension
install.rdf
Information, IDs and metadata
<?xml version="1.0"?>
<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>brucewillis@robertnyman.com</em:id>

   
    <em:name>Bruce Willis demo extension</em:name>

   
    <em:version>1.0</em:version>

   
    <em:type>2</em:type>

   
    <em:creator>Robert Nyman</em:creator>

    
    <em:description>Finds document headings and replaces them with Die
Hard movie titles</em:description>

   
    <em:homepageURL>http://www.robertnyman.com/</em:homepageURL>

    
    <em:optionsURL>chrome://brucewillis/content/preferences.xul</
em:optionsURL>



   
    <em:targetApplication>

   
    
    <Description>

   
    
    
      <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>

   
    
    
      <em:minVersion>2.0</em:minVersion>

   
    
    
      <em:maxVersion>3.1b2</em:maxVersion>

   
    
    </Description>

   
    </em:targetApplication>

   </Description>
</RDF>
How To Write Your First Firefox Extension
In the Description node
em:id
Your unique developer id, of your own choosing. Has to be the same as the pointer
file you previously created, i.e. brucewillis@robertnyman.com

em:name
The name of your extension.

em:version
Current version of your extension.

em:type
The type declares that it is an extension, as opposed to, for instance, a theme.

em:creator
You!

em:description
Describes your extension functionality. Will be shown in the Tools > Add-ons window.

em:homepageURL
The URL of your extension’s web site.

em:optionsURL
The URL to where you will have your file for editing options/preferences.
In the Description/
em:TargetApplication node
em:id
The actual id of Firefox: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}. Exchange
this to develop for another app, like Thunderbird.

em:minVersion
The minimum version number of Firefox to run the extension.

em:maxVersion
The maximum version number of Firefox to run the extension.



Valid alternatives for Firefox, Thunderbird etc and their corresponding versions
<?xml version="1.0"?>
<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>brucewillis@robertnyman.com</em:id>

   
    <em:name>Bruce Willis demo extension</em:name>

   
    <em:version>1.0</em:version>

   
    <em:type>2</em:type>

   
    <em:creator>Robert Nyman</em:creator>

    
    <em:description>Finds document headings and replaces them with Die
Hard movie titles</em:description>

   
    <em:homepageURL>http://www.robertnyman.com/</em:homepageURL>

    
    <em:optionsURL>chrome://brucewillis/content/preferences.xul</
em:optionsURL>



   
    <em:targetApplication>

   
    
    <Description>

   
    
    
      <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>

   
    
    
      <em:minVersion>2.0</em:minVersion>

   
    
    
      <em:maxVersion>3.1b2</em:maxVersion>

   
    
    </Description>

   
    </em:targetApplication>

   </Description>
</RDF>
More information in Install Manifests
chrome.manifest
File references and usage
content     brucewillis    chrome/content/

content     brucewillis    chrome/content/ contentaccessible=yes

overlay chrome://browser/content/browser.xul chrome://
brucewillis/content/browser.xul



locale
      brucewillis
 en-US
 chrome/locale/en-US/



skin
 brucewillis
 classic/1.0 chrome/skin/

style
 chrome://global/content/customizeToolbar.xul
chrome://
brucewillis/skin/skin.css
# Content pointer
content     brucewillis    chrome/content/


# Make content accessible from web pages in Firefox 3
content     brucewillis    chrome/content/ contentaccessible=yes


# Overlay browser skin
overlay chrome://browser/content/browser.xul chrome://
brucewillis/content/browser.xul
# Language versions
locale
      brucewillis
 en-US
 chrome/locale/en-US/
# Setting reference to extension skin
skin
 brucewillis
 classic/1.0 chrome/skin/


# Adding CSS to available toolbar buttons
style
 chrome://global/content/customizeToolbar.xul

 chrome://brucewillis/skin/skin.css
More information in Chrome Manifest
Are you with
 me so far?
chrome content folder
XUL, JavaScript and content CSS
XUL (“Zuul”) -
XML User Interface Language
  http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul
• browser.xul
• bruce-willis.css
• bruceWillis.js
• preferences.xul
• browser.xul
• bruce-willis.css
• bruceWillis.js
• preferences.xul
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://brucewillis/skin/skin.css" type="text/
css"?>
<!DOCTYPE window SYSTEM "chrome://brucewillis/locale/translations.dtd">
<overlay id="sample" xmlns="http://www.mozilla.org/keymaster/
gatekeeper/there.is.only.xul">

   
    <script src="bruceWillis.js" />

   

   
    <menupopup id="menu_ToolsPopup">

   
    
   <menuitem label="&runbrucewillis;" key="brucewillis-run-
key" oncommand="linkTargetFinder.run()"/>

   
    </menupopup>


   

   
    <keyset>

   
    
   <key id="brucewillis-run-key" modifiers="accel alt shift"
key="B" oncommand="bruceWillis.run()"/>

   
    </keyset>

   

   
    <statusbar id="status-bar">

   
    
   <statusbarpanel id="brucewillis-status-bar-icon"
class="statusbarpanel-iconic" src="chrome://brucewillis/skin/status-
bar.png" tooltiptext="&runbrucewillis;" onclick="bruceWillis.run()" />

   
    </statusbar>

   

   
    <toolbarpalette id="BrowserToolbarPalette">

   
    
   <toolbarbutton id="brucewillis-toolbar-button"
label="Bruce Willis" tooltiptext="&runbrucewillis;"
oncommand="bruceWillis.run()"/>

   
    </toolbarpalette>
</overlay>
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://brucewillis/skin/skin.css" type="text/
css"?>
<!DOCTYPE window SYSTEM "chrome://brucewillis/locale/translations.dtd">
<overlay id="sample" xmlns="http://www.mozilla.org/keymaster/
gatekeeper/there.is.only.xul">
      <script src="bruceWillis.js" />
      <!-- Content -->
</overlay>
<!-- Tools menu option and keyboard shortcut -->
         <menupopup id="menu_ToolsPopup">

   
    
   <menuitem label="&runbrucewillis;" key="brucewillis-run-
key" oncommand="linkTargetFinder.run()"/>

   
    </menupopup>


   
      <keyset>

   
      
   <key id="brucewillis-run-key" modifiers="accel alt shift"
key="B"   oncommand="bruceWillis.run()"/>

   
      </keyset>
How To Write Your First Firefox Extension
<!-- Statusbar icon -->
         <statusbar id="status-bar">

   
    
   <statusbarpanel id="brucewillis-status-bar-icon"
class="statusbarpanel-iconic" src="chrome://brucewillis/skin/status-
bar.png" tooltiptext="&runbrucewillis;" onclick="bruceWillis.run()" />

   
    </statusbar>
How To Write Your First Firefox Extension
<!-- Firefox toolbar button -->

   
    <toolbarpalette id="BrowserToolbarPalette">

   
    
   <toolbarbutton id="brucewillis-toolbar-button"
label="Bruce Willis" tooltiptext="&runbrucewillis;"
oncommand="bruceWillis.run()"/>

   
    </toolbarpalette>
How To Write Your First Firefox Extension
• browser.xul
• bruce-willis.css
• bruceWillis.js
• preferences.xul
h1, h2, h3, h4 {

 font-family: Georgia, Times, serif;
}
• browser.xul
• bruce-willis.css
• bruceWillis.js
• preferences.xul
var bruceWillis = function () {

      var prefManager = Components.classes["@mozilla.org/preferences-service;
1"].getService(Components.interfaces.nsIPrefBranch);

      return {

      
      init : function () {

      
      
      gBrowser.addEventListener("load", function () {

      
      
      
      var autoRun = prefManager.getBoolPref("extensions.brucewillis.autorun");

      
      
      
      if (autoRun) {

      
      
      
      
      bruceWillis.run();

      
      
      
      }

      
      
      }, false);

      
      },

      
      

      
      run : function () {

      
      
      var head = content.document.getElementsByTagName("head")[0],

      
      
      
      style = content.document.getElementById("bruce-willis-style"),

      
      
      
      h1 = content.document.getElementsByTagName("h1"),

      
      
      
      h2 = content.document.getElementsByTagName("h2"),

      
      
      
      h3 = content.document.getElementsByTagName("h3"),

      
      
      
      h4 = content.document.getElementsByTagName("h4");

      
      

      
      
      if (!style) {

      
      
      
      style = content.document.createElement("link");

      
      
      
      style.id = "brucewillis-style";

      
      
      
      style.type = "text/css";

      
      
      
      style.rel = "stylesheet";

      
      
      
      style.href = "chrome://brucewillis/content/bruce-willis.css";

      
      
      
      head.appendChild(style);

      
      
      }


      
      
      for (var i=0, il=h1.length; i<il; i++) {

      
      
      
      h1[i].textContent = "Die Hard 1";

      
      
      }

      
      

      
      
      for (var i=0, il=h2.length; i<il; i++) {

      
      
      
      h2[i].textContent = "Die Hard 2";

      
      
      }

      
      

      
      
      for (var i=0, il=h3.length; i<il; i++) {

      
      
      
      h3[i].textContent = "Die Hard 3";

      
      
      }

      
      

      
      
      for (var i=0, il=h4.length; i<il; i++) {

      
      
      
      h4[i].textContent = "Die Hard 4";

      
      
      }

      
      }

      };
}();
window.addEventListener("DOMContentLoaded", bruceWillis.init, false);
// Structure - Yahoo JavaScript Module Pattern
var bruceWillis = function () {

    var prefManager = Components.classes["@mozilla.org/preferences-
service;1"].getService(Components.interfaces.nsIPrefBranch);

    return {

    
   init : function () {
             // init method

    
   },

    
   

    
   run : function () {
             // run method

    
   }

    };
}();
window.addEventListener("DOMContentLoaded", bruceWillis.init, false);
// init method

   
    init : function () {

   
    
   gBrowser.addEventListener("load", function () {

   
    
   
    var autoRun =
prefManager.getBoolPref("extensions.brucewillis.autorun");

   
    
   
    if (autoRun) {

   
    
   
    
   bruceWillis.run();

   
    
   
    }

   
    
   }, false);

   
    }
// run method

   
   run : function () {

   
   
    var head = content.document.getElementsByTagName("head")[0],

   
   
    
     style = content.document.getElementById("bruce-willis-style"),

   
   
    
     h1 = content.document.getElementsByTagName("h1"),

   
   
    
     h2 = content.document.getElementsByTagName("h2"),

   
   
    
     h3 = content.document.getElementsByTagName("h3"),

   
   
    
     h4 = content.document.getElementsByTagName("h4");

   
   

   
   
    if (!style) {

   
   
    
     style = content.document.createElement("link");

   
   
    
     style.id = "brucewillis-style";

   
   
    
     style.type = "text/css";

   
   
    
     style.rel = "stylesheet";

   
   
    
     style.href = "chrome://brucewillis/content/bruce-willis.css";

   
   
    
     head.appendChild(style);

   
   
    }


   
   
    for (var i=0, il=h1.length; i<il; i++) {

   
   
    
    h1[i].textContent = "Die Hard 1";

   
   
    }

   
   

   
   
    for (var i=0, il=h2.length; i<il; i++) {

   
   
    
    h2[i].textContent = "Die Hard 2";

   
   
    }

   
   

   
   
    for (var i=0, il=h3.length; i<il; i++) {

   
   
    
    h3[i].textContent = "Die Hard 3";

   
   
    }

   
   

   
   
    for (var i=0, il=h4.length; i<il; i++) {

   
   
    
    h4[i].textContent = "Die Hard 4";

   
   
    }

   
   }
// Run when DOM has loaded
window.addEventListener("DOMContentLoaded", bruceWillis.init, false);
• browser.xul
• bruce-willis.css
• bruceWillis.js
• preferences.xul
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<prefwindow
     title="Bruce Willis Preferences"
     xmlns="http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul">


   <prefpane label="Bruce Willis Preferences">

   
    <preferences>

   
    
   <preference id="brucewillis-autorun"
name="extensions.brucewillis.autorun" type="bool"/>

   
    </preferences>

   

   
    <groupbox>

   
    
   <caption label="Settings"/>

   
    
   <grid>

   
    
   
    <columns>

   
    
   
    
   <column flex="4"/>

   
    
   
    
   <column flex="1"/>

   
    
   
    </columns>

   
    
   
    <rows>

   
    
   
    
   <row>

   
    
   
    
   
    <label control="autorun" value="Autorun"/>

   
    
   
    
   
    <checkbox id="autorun"
preference="brucewillis-autorun"/>

   
    
   
    
   </row>

   
    
   
    </rows>

   
    
   </grid>

   
    </groupbox>

   

   </prefpane>

</prefwindow>
<!-- Connect element to extension preference -->

   
    <preferences>

   
    
   <preference id="brucewillis-autorun"
name="extensions.brucewillis.autorun" type="bool"/>

   
    </preferences>

   


   
   <checkbox id="autorun" preference="brucewillis-autorun"/>
How To Write Your First Firefox Extension
chrome locale folder
Offering localization
translations.dtd:

<!ENTITY runbrucewillis "Run Bruce Willis">
chrome skins folder
Skin your extension with CSS and images
• skin.css
• status-bar.png
• toolbar-button.png
/* skin.css */


/* Style in View > Toolbars > Customize */
#brucewillis-toolbar-button {

   list-style-image: url(chrome://brucewillis/skin/toolbar-
button.png);
}


#brucewillis-status-bar-icon {

   width: 83px;

   margin: 0 5px;
}
/* status-bar.png */
/* toolbar-button.png */
preferences - defaults folder
Setting default extension values
// prefs.js

pref("extensions.brucewillis.autorun", false);
Packaging & Installing
An XPI (“zippy”) is just a zipped file
ZIP the contents of your extension folder
(only the contents, NOT the folder itself)
Windows:

Mark all files, right-click and choose:
Send To > Compressed
Rename ZIP file to .xpi

Mac OS X/Linux (in Terminal):

Navigate to your extension files. Type in:
zip -r BruceWillis.xpi *
Drag your XPI file into Firefox - Voilà!
What it looks like
Before
After
Distributing Your
    Add-On
addons.mozilla.org
or through secure location (SSL)


Successfully Getting your Addon Reviewed
Downloads
• Download Bruce Willis extension
• Browse source files
• Presentation slides at:
  http://robertnyman.com/speaking/
Learn more
Learn by looking at others
In your Profile folder
What you’ve learned
1. Create development profile
2. Configuration settings
3. Pointing extension to your dev directory
4. Creating folder structure & files
5. Packaging & installing
6. Distributing your add-on
That’s it!
How To Write Your First Firefox Extension
Robert Nyman
                     robert@robertnyman.com
                      http://robertnyman.com
Images:
    http://www.learningresources.com/product/teachers/shop+by+category/activity+kits/construction/m--8226-
    gears--174-+building+set.do
    http://www.soitenlystooges.com/item.asp?sku=FGSU578
    http://www.flickr.com/photos/28791486@N03/2700643931/
    http://www.fetasteutgavan.se/blogg/wp/?p=39
    http://www.pixabella.com/plugin/tag/red-hearts
    http://www.woodlands-junior.kent.sch.uk/customs/xmas/calendar/day13.html
    http://www.intercan.org/coordinator_list.asp
1 of 103

Recommended

Firefox addons by
Firefox addonsFirefox addons
Firefox addonsGurpreet Singh Sachdeva
907 views11 slides
Firefox extension Development by
Firefox extension DevelopmentFirefox extension Development
Firefox extension DevelopmentAbhinav Chittora
3.6K views89 slides
Firefox Extension Development by
Firefox Extension DevelopmentFirefox Extension Development
Firefox Extension Developmentphamvanvung
2.6K views31 slides
18. images in symfony 4 by
18. images in symfony 418. images in symfony 4
18. images in symfony 4Razvan Raducanu, PhD
78 views14 slides
Php login system with admin features evolt by
Php login system with admin features   evoltPhp login system with admin features   evolt
Php login system with admin features evoltGIMT
15.8K views25 slides
WordPress Theme Development by
 WordPress Theme Development WordPress Theme Development
WordPress Theme DevelopmentBijay Oli
3K views27 slides

More Related Content

What's hot

Hpage by
HpageHpage
HpageSvetoslav Nikolov
294 views22 slides
Creating a basic joomla by
Creating a basic joomlaCreating a basic joomla
Creating a basic joomlashailendra vishwakarma
682 views8 slides
Cms & wordpress theme development 2011 by
Cms & wordpress theme development 2011Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Dave Wallace
2K views83 slides
CustomThesis by
CustomThesisCustomThesis
CustomThesistutorialsruby
582 views24 slides
Introduction to WordPress Theme Development by
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentSitdhibong Laokok
7.7K views17 slides
PHP記帳網頁教材(第一頁是空白的) by
PHP記帳網頁教材(第一頁是空白的)PHP記帳網頁教材(第一頁是空白的)
PHP記帳網頁教材(第一頁是空白的)TaiShunHuang
2.1K views49 slides

What's hot(20)

Cms & wordpress theme development 2011 by Dave Wallace
Cms & wordpress theme development 2011Cms & wordpress theme development 2011
Cms & wordpress theme development 2011
Dave Wallace2K views
Introduction to WordPress Theme Development by Sitdhibong Laokok
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme Development
Sitdhibong Laokok7.7K views
PHP記帳網頁教材(第一頁是空白的) by TaiShunHuang
PHP記帳網頁教材(第一頁是空白的)PHP記帳網頁教材(第一頁是空白的)
PHP記帳網頁教材(第一頁是空白的)
TaiShunHuang2.1K views
WebMatrix 100-level presentation by Alice Pang
WebMatrix 100-level presentationWebMatrix 100-level presentation
WebMatrix 100-level presentation
Alice Pang657 views
Architecture of Drupal - Drupal Camp by Dipen Chaudhary
Architecture of Drupal - Drupal CampArchitecture of Drupal - Drupal Camp
Architecture of Drupal - Drupal Camp
Dipen Chaudhary8.4K views
Whmcs addon module docs by quyvn
Whmcs addon module docsWhmcs addon module docs
Whmcs addon module docs
quyvn5.3K views
Installing And Configuration for your Wordpress blog by igorgentry
Installing And Configuration for your Wordpress blogInstalling And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blog
igorgentry412 views
4.content mgmt by Wingston
4.content mgmt4.content mgmt
4.content mgmt
Wingston1.1K views
Death of a Themer by James Panton
Death of a ThemerDeath of a Themer
Death of a Themer
James Panton4.3K views
I use drupal / 我是 OO 師,我用 Drupal by Chris Wu
I use drupal / 我是 OO 師,我用 DrupalI use drupal / 我是 OO 師,我用 Drupal
I use drupal / 我是 OO 師,我用 Drupal
Chris Wu2.9K views
Drupal 8 Theme System: The Backend of Frontend by Acquia
Drupal 8 Theme System: The Backend of FrontendDrupal 8 Theme System: The Backend of Frontend
Drupal 8 Theme System: The Backend of Frontend
Acquia1.2K views
Drupal vs WordPress by Walter Ebert
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPress
Walter Ebert2.1K views
WordPress Theme Development by WisdmLabs
WordPress Theme DevelopmentWordPress Theme Development
WordPress Theme Development
WisdmLabs533 views
Moodle 3.3 - API Change Overview #mootieuk17 by Dan Poltawski
Moodle 3.3 - API Change Overview #mootieuk17Moodle 3.3 - API Change Overview #mootieuk17
Moodle 3.3 - API Change Overview #mootieuk17
Dan Poltawski1.2K views
C3 웹기술로만드는모바일앱 by NAVER D2
C3 웹기술로만드는모바일앱C3 웹기술로만드는모바일앱
C3 웹기술로만드는모바일앱
NAVER D21.1K views

Viewers also liked

Place graphs are the new social graphs by
Place graphs are the new social graphsPlace graphs are the new social graphs
Place graphs are the new social graphsMatt Biddulph
17.6K views20 slides
by
Roshan Titus
12.8K views21 slides
How to do presentations that don't induce suicide by
How to do presentations that don't induce suicideHow to do presentations that don't induce suicide
How to do presentations that don't induce suicideAndy Whitlock
43.1K views52 slides
Spanish translation (my school day) by
Spanish translation (my school day)Spanish translation (my school day)
Spanish translation (my school day)tc776618mhs
1.9K views1 slide
Testo Instruments 2012 overview by
Testo Instruments 2012 overviewTesto Instruments 2012 overview
Testo Instruments 2012 overviewTesto Limited
2.2K views20 slides
Struts2 - 101 by
Struts2 - 101Struts2 - 101
Struts2 - 101Munish Gupta
2.5K views98 slides

Viewers also liked(20)

Place graphs are the new social graphs by Matt Biddulph
Place graphs are the new social graphsPlace graphs are the new social graphs
Place graphs are the new social graphs
Matt Biddulph17.6K views
How to do presentations that don't induce suicide by Andy Whitlock
How to do presentations that don't induce suicideHow to do presentations that don't induce suicide
How to do presentations that don't induce suicide
Andy Whitlock43.1K views
Spanish translation (my school day) by tc776618mhs
Spanish translation (my school day)Spanish translation (my school day)
Spanish translation (my school day)
tc776618mhs1.9K views
Testo Instruments 2012 overview by Testo Limited
Testo Instruments 2012 overviewTesto Instruments 2012 overview
Testo Instruments 2012 overview
Testo Limited2.2K views
Assgn. 1 essay question traditional houses by suehwa533
Assgn. 1 essay question   traditional housesAssgn. 1 essay question   traditional houses
Assgn. 1 essay question traditional houses
suehwa5331.2K views
Extending the Virtual World Framework for Mobile Training by Ronald Punako, Jr.
Extending the Virtual World Framework for Mobile TrainingExtending the Virtual World Framework for Mobile Training
Extending the Virtual World Framework for Mobile Training
Ronald Punako, Jr.1.4K views
The home and the world by RoyB
The home and the worldThe home and the world
The home and the world
RoyB 11.8K views
Perubahan entalpi reaksi menggunakan kalorimeter sederhana by Sabrianah Badaruddin
Perubahan entalpi reaksi menggunakan kalorimeter sederhanaPerubahan entalpi reaksi menggunakan kalorimeter sederhana
Perubahan entalpi reaksi menggunakan kalorimeter sederhana
Sabrianah Badaruddin32.7K views
Vulva hygiene by risdiana21
Vulva hygieneVulva hygiene
Vulva hygiene
risdiana2115.4K views
Value analysis and Value Engineering in Cost Control by sunilrajpawar
Value analysis and Value Engineering in Cost ControlValue analysis and Value Engineering in Cost Control
Value analysis and Value Engineering in Cost Control
sunilrajpawar2.9K views
a manual of wood-Carving. by zuhairbuzid
a manual of wood-Carving.a manual of wood-Carving.
a manual of wood-Carving.
zuhairbuzid10.6K views
Confucius on Leadership by Richard Brown
Confucius on LeadershipConfucius on Leadership
Confucius on Leadership
Richard Brown3.6K views
iPhone Coding For Web Developers by Matt Biddulph
iPhone Coding For Web DevelopersiPhone Coding For Web Developers
iPhone Coding For Web Developers
Matt Biddulph38.8K views
Redis everywhere - PHP London by Ricard Clau
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
Ricard Clau28K views

Similar to How To Write Your First Firefox Extension

Polymer 1.0 by
Polymer 1.0Polymer 1.0
Polymer 1.0Cyril Balit
346 views70 slides
HTML5 New and Improved by
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and ImprovedTimothy Fisher
6.8K views46 slides
JavaScript DOM - Dynamic interactive Code by
JavaScript DOM - Dynamic interactive CodeJavaScript DOM - Dynamic interactive Code
JavaScript DOM - Dynamic interactive CodeLaurence Svekis ✔
221 views62 slides
How to create a basic template by
How to create a basic templateHow to create a basic template
How to create a basic templatevathur
360 views13 slides
Yuihacku iitd-sumana by
Yuihacku iitd-sumanaYuihacku iitd-sumana
Yuihacku iitd-sumanaSumana Hariharan
551 views16 slides
Cliw - extension development by
Cliw -  extension developmentCliw -  extension development
Cliw - extension developmentvicccuu
835 views27 slides

Similar to How To Write Your First Firefox Extension(20)

How to create a basic template by vathur
How to create a basic templateHow to create a basic template
How to create a basic template
vathur360 views
Cliw - extension development by vicccuu
Cliw -  extension developmentCliw -  extension development
Cliw - extension development
vicccuu835 views
Joomla Beginner Template Presentation by alledia
Joomla Beginner Template PresentationJoomla Beginner Template Presentation
Joomla Beginner Template Presentation
alledia2.1K views
Web development - technologies and tools by Yoann Gotthilf
Web development - technologies and toolsWeb development - technologies and tools
Web development - technologies and tools
Yoann Gotthilf1.1K views
Advanced Thesis Techniques and Tricks by Brad Williams
Advanced Thesis Techniques and TricksAdvanced Thesis Techniques and Tricks
Advanced Thesis Techniques and Tricks
Brad Williams3.5K views
Building Potent WordPress Websites by Kyle Cearley
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
Kyle Cearley2.5K views
“Good design is obvious. Great design is transparent.” — How we use Bootstrap... by Roni Banerjee
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
“Good design is obvious. Great design is transparent.” — How we use Bootstrap...
Roni Banerjee164 views
Ember: Guts & Goals by Bob Lail
Ember: Guts & GoalsEmber: Guts & Goals
Ember: Guts & Goals
Bob Lail313 views
Bootstrap 3 by McSoftsis
Bootstrap 3Bootstrap 3
Bootstrap 3
McSoftsis2.1K views
How to make a WordPress theme by Hardeep Asrani
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress theme
Hardeep Asrani492 views
WordPress theme development from scratch : ICT MeetUp 2013 Nepal by Chandra Prakash Thapa
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
Chandra Prakash Thapa18.4K views

More from Robert Nyman

Have you tried listening? by
Have you tried listening?Have you tried listening?
Have you tried listening?Robert Nyman
14.2K views63 slides
Building for Your Next Billion - Google I/O 2017 by
Building for Your Next Billion - Google I/O 2017Building for Your Next Billion - Google I/O 2017
Building for Your Next Billion - Google I/O 2017Robert Nyman
8.6K views109 slides
Introduction to Google Daydream by
Introduction to Google DaydreamIntroduction to Google Daydream
Introduction to Google DaydreamRobert Nyman
4.1K views29 slides
Predictability for the Web by
Predictability for the WebPredictability for the Web
Predictability for the WebRobert Nyman
12K views74 slides
The Future of Progressive Web Apps - View Source conference, Berlin 2016 by
The Future of Progressive Web Apps - View Source conference, Berlin 2016The Future of Progressive Web Apps - View Source conference, Berlin 2016
The Future of Progressive Web Apps - View Source conference, Berlin 2016Robert Nyman
14.1K views122 slides
The Future of the Web - Cold Front conference 2016 by
The Future of the Web - Cold Front conference 2016The Future of the Web - Cold Front conference 2016
The Future of the Web - Cold Front conference 2016Robert Nyman
13.2K views120 slides

More from Robert Nyman(20)

Have you tried listening? by Robert Nyman
Have you tried listening?Have you tried listening?
Have you tried listening?
Robert Nyman14.2K views
Building for Your Next Billion - Google I/O 2017 by Robert Nyman
Building for Your Next Billion - Google I/O 2017Building for Your Next Billion - Google I/O 2017
Building for Your Next Billion - Google I/O 2017
Robert Nyman8.6K views
Introduction to Google Daydream by Robert Nyman
Introduction to Google DaydreamIntroduction to Google Daydream
Introduction to Google Daydream
Robert Nyman4.1K views
Predictability for the Web by Robert Nyman
Predictability for the WebPredictability for the Web
Predictability for the Web
Robert Nyman12K views
The Future of Progressive Web Apps - View Source conference, Berlin 2016 by Robert Nyman
The Future of Progressive Web Apps - View Source conference, Berlin 2016The Future of Progressive Web Apps - View Source conference, Berlin 2016
The Future of Progressive Web Apps - View Source conference, Berlin 2016
Robert Nyman14.1K views
The Future of the Web - Cold Front conference 2016 by Robert Nyman
The Future of the Web - Cold Front conference 2016The Future of the Web - Cold Front conference 2016
The Future of the Web - Cold Front conference 2016
Robert Nyman13.2K views
The Future of Progressive Web Apps - Google for Indonesia by Robert Nyman
The Future of Progressive Web Apps - Google for IndonesiaThe Future of Progressive Web Apps - Google for Indonesia
The Future of Progressive Web Apps - Google for Indonesia
Robert Nyman16.5K views
Google tech & products by Robert Nyman
Google tech & productsGoogle tech & products
Google tech & products
Robert Nyman16.2K views
Introduction to Progressive Web Apps, Google Developer Summit, Seoul - South ... by Robert Nyman
Introduction to Progressive Web Apps, Google Developer Summit, Seoul - South ...Introduction to Progressive Web Apps, Google Developer Summit, Seoul - South ...
Introduction to Progressive Web Apps, Google Developer Summit, Seoul - South ...
Robert Nyman16.2K views
Progressive Web Apps keynote, Google Developer Summit, Tokyo, Japan by Robert Nyman
Progressive Web Apps keynote, Google Developer Summit, Tokyo, JapanProgressive Web Apps keynote, Google Developer Summit, Tokyo, Japan
Progressive Web Apps keynote, Google Developer Summit, Tokyo, Japan
Robert Nyman8.8K views
The web - What it has, what it lacks and where it must go - keynote at Riga D... by Robert Nyman
The web - What it has, what it lacks and where it must go - keynote at Riga D...The web - What it has, what it lacks and where it must go - keynote at Riga D...
The web - What it has, what it lacks and where it must go - keynote at Riga D...
Robert Nyman13.4K views
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ... by Robert Nyman
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
The web - What it has, what it lacks and where it must go - Bulgaria Web Summ...
Robert Nyman13K views
The web - What it has, what it lacks and where it must go - Istanbul by Robert Nyman
The web - What it has, what it lacks and where it must go - IstanbulThe web - What it has, what it lacks and where it must go - Istanbul
The web - What it has, what it lacks and where it must go - Istanbul
Robert Nyman29.1K views
The web - What it has, what it lacks and where it must go by Robert Nyman
The web - What it has, what it lacks and where it must goThe web - What it has, what it lacks and where it must go
The web - What it has, what it lacks and where it must go
Robert Nyman36.2K views
Google, the future and possibilities by Robert Nyman
Google, the future and possibilitiesGoogle, the future and possibilities
Google, the future and possibilities
Robert Nyman9.1K views
Developer Relations in the Nordics by Robert Nyman
Developer Relations in the NordicsDeveloper Relations in the Nordics
Developer Relations in the Nordics
Robert Nyman3.7K views
What is Developer Relations? by Robert Nyman
What is Developer Relations?What is Developer Relations?
What is Developer Relations?
Robert Nyman7.4K views
Android TV Introduction - Stockholm Android TV meetup by Robert Nyman
Android TV Introduction - Stockholm Android TV meetupAndroid TV Introduction - Stockholm Android TV meetup
Android TV Introduction - Stockholm Android TV meetup
Robert Nyman8.1K views
New improvements for web developers - frontend.fi, Helsinki by Robert Nyman
New improvements for web developers - frontend.fi, HelsinkiNew improvements for web developers - frontend.fi, Helsinki
New improvements for web developers - frontend.fi, Helsinki
Robert Nyman7.5K views
Mobile phone trends, user data & developer climate - frontend.fi, Helsinki by Robert Nyman
Mobile phone trends, user data & developer climate - frontend.fi, HelsinkiMobile phone trends, user data & developer climate - frontend.fi, Helsinki
Mobile phone trends, user data & developer climate - frontend.fi, Helsinki
Robert Nyman4.4K views

Recently uploaded

Java Platform Approach 1.0 - Picnic Meetup by
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic MeetupRick Ossendrijver
25 views39 slides
Combining Orchestration and Choreography for a Clean Architecture by
Combining Orchestration and Choreography for a Clean ArchitectureCombining Orchestration and Choreography for a Clean Architecture
Combining Orchestration and Choreography for a Clean ArchitectureThomasHeinrichs1
69 views24 slides
handbook for web 3 adoption.pdf by
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdfLiveplex
19 views16 slides
Perth MeetUp November 2023 by
Perth MeetUp November 2023 Perth MeetUp November 2023
Perth MeetUp November 2023 Michael Price
15 views44 slides
[2023] Putting the R! in R&D.pdf by
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdfEleanor McHugh
38 views127 slides
Attacking IoT Devices from a Web Perspective - Linux Day by
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day Simone Onofri
15 views68 slides

Recently uploaded(20)

Combining Orchestration and Choreography for a Clean Architecture by ThomasHeinrichs1
Combining Orchestration and Choreography for a Clean ArchitectureCombining Orchestration and Choreography for a Clean Architecture
Combining Orchestration and Choreography for a Clean Architecture
ThomasHeinrichs169 views
handbook for web 3 adoption.pdf by Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex19 views
Perth MeetUp November 2023 by Michael Price
Perth MeetUp November 2023 Perth MeetUp November 2023
Perth MeetUp November 2023
Michael Price15 views
[2023] Putting the R! in R&D.pdf by Eleanor McHugh
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh38 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 views
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze by NUS-ISS
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng TszeDigital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
Digital Product-Centric Enterprise and Enterprise Architecture - Tan Eng Tsze
NUS-ISS19 views
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab15 views
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2216 views
Spesifikasi Lengkap ASUS Vivobook Go 14 by Dot Semarang
Spesifikasi Lengkap ASUS Vivobook Go 14Spesifikasi Lengkap ASUS Vivobook Go 14
Spesifikasi Lengkap ASUS Vivobook Go 14
Dot Semarang35 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software225 views
How the World's Leading Independent Automotive Distributor is Reinventing Its... by NUS-ISS
How the World's Leading Independent Automotive Distributor is Reinventing Its...How the World's Leading Independent Automotive Distributor is Reinventing Its...
How the World's Leading Independent Automotive Distributor is Reinventing Its...
NUS-ISS15 views
AI: mind, matter, meaning, metaphors, being, becoming, life values by Twain Liu 刘秋艳
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life values
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta15 views
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum... by NUS-ISS
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
NUS-ISS34 views
Web Dev - 1 PPT.pdf by gdsczhcet
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdf
gdsczhcet55 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst470 views
.conf Go 2023 - Data analysis as a routine by Splunk
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routine
Splunk93 views

How To Write Your First Firefox Extension

  • 1. How to Write Your First Extension
  • 3. Bruce Willis Extension (Francois Mori/AP Photo)
  • 4. How to Write Your First Extension 1. Create development profile 2. Configuration settings 3. Pointing extension to your dev directory 4. Creating folder structure & files 5. Packaging & installing 6. Distributing your add-on
  • 6. Keep a separate Firefox profile for extension development
  • 7. Windows: Start menu > Run (Windows key + R). Write firefox -P and press click OK. Mac OS X (in Terminal): Type in /Applications/Firefox.app/ Contents/MacOS/firefox - profilemanager Linux (in a terminal): Use cd to navigate to your Firefox directory and then enter ./firefox -profilemanager
  • 11. Pointing Extension to Your Development Directory
  • 12. Find your Profile directory
  • 13. Windows: Win XP: C:Documents and Settings[user name] Application DataMozillaFirefoxProfiles Vista: C:Users[user name]AppDataRoaming Mac OS X (~ = /Users/[user name]): ~/Library/Application Support/Firefox/Profiles/ Linux: ~/.mozilla/
  • 14. Go to [Dev Profile]/extensions/ folder
  • 15. Create empty file (no file extension!): brucewillis@robertnyman.com
  • 17. Point to your extension code, i.e. file path: Windows: E.g: C:devbrucewillis Mac/Linux: E.g: ~/dev/brucewillis/
  • 19. 1. Open Firefox: - Have your development profile as default - or Through Profile Manager 2. Type in about:config
  • 21. Recommended settings: javascript.options.showInConsole = true nglayout.debug.disable_xul_cache = true browser.dom.window.dump.enabled = true
  • 22. • Optional settings: javascript.options.strict = true extensions.logging.enabled = true
  • 27. • Automatic creation of extension • Extension Developer extension
  • 30. <?xml version="1.0"?> <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>brucewillis@robertnyman.com</em:id> <em:name>Bruce Willis demo extension</em:name> <em:version>1.0</em:version> <em:type>2</em:type> <em:creator>Robert Nyman</em:creator> <em:description>Finds document headings and replaces them with Die Hard movie titles</em:description> <em:homepageURL>http://www.robertnyman.com/</em:homepageURL> <em:optionsURL>chrome://brucewillis/content/preferences.xul</ em:optionsURL> <em:targetApplication> <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>2.0</em:minVersion> <em:maxVersion>3.1b2</em:maxVersion> </Description> </em:targetApplication> </Description> </RDF>
  • 33. em:id Your unique developer id, of your own choosing. Has to be the same as the pointer file you previously created, i.e. brucewillis@robertnyman.com em:name The name of your extension. em:version Current version of your extension. em:type The type declares that it is an extension, as opposed to, for instance, a theme. em:creator You! em:description Describes your extension functionality. Will be shown in the Tools > Add-ons window. em:homepageURL The URL of your extension’s web site. em:optionsURL The URL to where you will have your file for editing options/preferences.
  • 35. em:id The actual id of Firefox: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}. Exchange this to develop for another app, like Thunderbird. em:minVersion The minimum version number of Firefox to run the extension. em:maxVersion The maximum version number of Firefox to run the extension. Valid alternatives for Firefox, Thunderbird etc and their corresponding versions
  • 36. <?xml version="1.0"?> <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>brucewillis@robertnyman.com</em:id> <em:name>Bruce Willis demo extension</em:name> <em:version>1.0</em:version> <em:type>2</em:type> <em:creator>Robert Nyman</em:creator> <em:description>Finds document headings and replaces them with Die Hard movie titles</em:description> <em:homepageURL>http://www.robertnyman.com/</em:homepageURL> <em:optionsURL>chrome://brucewillis/content/preferences.xul</ em:optionsURL> <em:targetApplication> <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>2.0</em:minVersion> <em:maxVersion>3.1b2</em:maxVersion> </Description> </em:targetApplication> </Description> </RDF>
  • 37. More information in Install Manifests
  • 40. content brucewillis chrome/content/ content brucewillis chrome/content/ contentaccessible=yes overlay chrome://browser/content/browser.xul chrome:// brucewillis/content/browser.xul locale brucewillis en-US chrome/locale/en-US/ skin brucewillis classic/1.0 chrome/skin/ style chrome://global/content/customizeToolbar.xul chrome:// brucewillis/skin/skin.css
  • 41. # Content pointer content brucewillis chrome/content/ # Make content accessible from web pages in Firefox 3 content brucewillis chrome/content/ contentaccessible=yes # Overlay browser skin overlay chrome://browser/content/browser.xul chrome:// brucewillis/content/browser.xul
  • 42. # Language versions locale brucewillis en-US chrome/locale/en-US/
  • 43. # Setting reference to extension skin skin brucewillis classic/1.0 chrome/skin/ # Adding CSS to available toolbar buttons style chrome://global/content/customizeToolbar.xul chrome://brucewillis/skin/skin.css
  • 44. More information in Chrome Manifest
  • 45. Are you with me so far?
  • 47. XUL, JavaScript and content CSS
  • 48. XUL (“Zuul”) - XML User Interface Language http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul
  • 49. • browser.xul • bruce-willis.css • bruceWillis.js • preferences.xul
  • 50. • browser.xul • bruce-willis.css • bruceWillis.js • preferences.xul
  • 51. <?xml version="1.0"?> <?xml-stylesheet href="chrome://brucewillis/skin/skin.css" type="text/ css"?> <!DOCTYPE window SYSTEM "chrome://brucewillis/locale/translations.dtd"> <overlay id="sample" xmlns="http://www.mozilla.org/keymaster/ gatekeeper/there.is.only.xul"> <script src="bruceWillis.js" /> <menupopup id="menu_ToolsPopup"> <menuitem label="&runbrucewillis;" key="brucewillis-run- key" oncommand="linkTargetFinder.run()"/> </menupopup> <keyset> <key id="brucewillis-run-key" modifiers="accel alt shift" key="B" oncommand="bruceWillis.run()"/> </keyset> <statusbar id="status-bar"> <statusbarpanel id="brucewillis-status-bar-icon" class="statusbarpanel-iconic" src="chrome://brucewillis/skin/status- bar.png" tooltiptext="&runbrucewillis;" onclick="bruceWillis.run()" /> </statusbar> <toolbarpalette id="BrowserToolbarPalette"> <toolbarbutton id="brucewillis-toolbar-button" label="Bruce Willis" tooltiptext="&runbrucewillis;" oncommand="bruceWillis.run()"/> </toolbarpalette> </overlay>
  • 52. <?xml version="1.0"?> <?xml-stylesheet href="chrome://brucewillis/skin/skin.css" type="text/ css"?> <!DOCTYPE window SYSTEM "chrome://brucewillis/locale/translations.dtd">
  • 53. <overlay id="sample" xmlns="http://www.mozilla.org/keymaster/ gatekeeper/there.is.only.xul"> <script src="bruceWillis.js" /> <!-- Content --> </overlay>
  • 54. <!-- Tools menu option and keyboard shortcut --> <menupopup id="menu_ToolsPopup"> <menuitem label="&runbrucewillis;" key="brucewillis-run- key" oncommand="linkTargetFinder.run()"/> </menupopup> <keyset> <key id="brucewillis-run-key" modifiers="accel alt shift" key="B" oncommand="bruceWillis.run()"/> </keyset>
  • 56. <!-- Statusbar icon --> <statusbar id="status-bar"> <statusbarpanel id="brucewillis-status-bar-icon" class="statusbarpanel-iconic" src="chrome://brucewillis/skin/status- bar.png" tooltiptext="&runbrucewillis;" onclick="bruceWillis.run()" /> </statusbar>
  • 58. <!-- Firefox toolbar button --> <toolbarpalette id="BrowserToolbarPalette"> <toolbarbutton id="brucewillis-toolbar-button" label="Bruce Willis" tooltiptext="&runbrucewillis;" oncommand="bruceWillis.run()"/> </toolbarpalette>
  • 60. • browser.xul • bruce-willis.css • bruceWillis.js • preferences.xul
  • 61. h1, h2, h3, h4 { font-family: Georgia, Times, serif; }
  • 62. • browser.xul • bruce-willis.css • bruceWillis.js • preferences.xul
  • 63. var bruceWillis = function () { var prefManager = Components.classes["@mozilla.org/preferences-service; 1"].getService(Components.interfaces.nsIPrefBranch); return { init : function () { gBrowser.addEventListener("load", function () { var autoRun = prefManager.getBoolPref("extensions.brucewillis.autorun"); if (autoRun) { bruceWillis.run(); } }, false); }, run : function () { var head = content.document.getElementsByTagName("head")[0], style = content.document.getElementById("bruce-willis-style"), h1 = content.document.getElementsByTagName("h1"), h2 = content.document.getElementsByTagName("h2"), h3 = content.document.getElementsByTagName("h3"), h4 = content.document.getElementsByTagName("h4"); if (!style) { style = content.document.createElement("link"); style.id = "brucewillis-style"; style.type = "text/css"; style.rel = "stylesheet"; style.href = "chrome://brucewillis/content/bruce-willis.css"; head.appendChild(style); } for (var i=0, il=h1.length; i<il; i++) { h1[i].textContent = "Die Hard 1"; } for (var i=0, il=h2.length; i<il; i++) { h2[i].textContent = "Die Hard 2"; } for (var i=0, il=h3.length; i<il; i++) { h3[i].textContent = "Die Hard 3"; } for (var i=0, il=h4.length; i<il; i++) { h4[i].textContent = "Die Hard 4"; } } }; }(); window.addEventListener("DOMContentLoaded", bruceWillis.init, false);
  • 64. // Structure - Yahoo JavaScript Module Pattern var bruceWillis = function () { var prefManager = Components.classes["@mozilla.org/preferences- service;1"].getService(Components.interfaces.nsIPrefBranch); return { init : function () { // init method }, run : function () { // run method } }; }(); window.addEventListener("DOMContentLoaded", bruceWillis.init, false);
  • 65. // init method init : function () { gBrowser.addEventListener("load", function () { var autoRun = prefManager.getBoolPref("extensions.brucewillis.autorun"); if (autoRun) { bruceWillis.run(); } }, false); }
  • 66. // run method run : function () { var head = content.document.getElementsByTagName("head")[0], style = content.document.getElementById("bruce-willis-style"), h1 = content.document.getElementsByTagName("h1"), h2 = content.document.getElementsByTagName("h2"), h3 = content.document.getElementsByTagName("h3"), h4 = content.document.getElementsByTagName("h4"); if (!style) { style = content.document.createElement("link"); style.id = "brucewillis-style"; style.type = "text/css"; style.rel = "stylesheet"; style.href = "chrome://brucewillis/content/bruce-willis.css"; head.appendChild(style); } for (var i=0, il=h1.length; i<il; i++) { h1[i].textContent = "Die Hard 1"; } for (var i=0, il=h2.length; i<il; i++) { h2[i].textContent = "Die Hard 2"; } for (var i=0, il=h3.length; i<il; i++) { h3[i].textContent = "Die Hard 3"; } for (var i=0, il=h4.length; i<il; i++) { h4[i].textContent = "Die Hard 4"; } }
  • 67. // Run when DOM has loaded window.addEventListener("DOMContentLoaded", bruceWillis.init, false);
  • 68. • browser.xul • bruce-willis.css • bruceWillis.js • preferences.xul
  • 69. <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <prefwindow title="Bruce Willis Preferences" xmlns="http://www.mozilla.org/keymaster/gatekeeper/ there.is.only.xul"> <prefpane label="Bruce Willis Preferences"> <preferences> <preference id="brucewillis-autorun" name="extensions.brucewillis.autorun" type="bool"/> </preferences> <groupbox> <caption label="Settings"/> <grid> <columns> <column flex="4"/> <column flex="1"/> </columns> <rows> <row> <label control="autorun" value="Autorun"/> <checkbox id="autorun" preference="brucewillis-autorun"/> </row> </rows> </grid> </groupbox> </prefpane> </prefwindow>
  • 70. <!-- Connect element to extension preference --> <preferences> <preference id="brucewillis-autorun" name="extensions.brucewillis.autorun" type="bool"/> </preferences> <checkbox id="autorun" preference="brucewillis-autorun"/>
  • 76. Skin your extension with CSS and images
  • 78. /* skin.css */ /* Style in View > Toolbars > Customize */ #brucewillis-toolbar-button { list-style-image: url(chrome://brucewillis/skin/toolbar- button.png); } #brucewillis-status-bar-icon { width: 83px; margin: 0 5px; }
  • 85. An XPI (“zippy”) is just a zipped file
  • 86. ZIP the contents of your extension folder (only the contents, NOT the folder itself)
  • 87. Windows: Mark all files, right-click and choose: Send To > Compressed Rename ZIP file to .xpi Mac OS X/Linux (in Terminal): Navigate to your extension files. Type in: zip -r BruceWillis.xpi *
  • 88. Drag your XPI file into Firefox - Voilà!
  • 91. After
  • 93. addons.mozilla.org or through secure location (SSL) Successfully Getting your Addon Reviewed
  • 95. • Download Bruce Willis extension • Browse source files • Presentation slides at: http://robertnyman.com/speaking/
  • 97. Learn by looking at others
  • 100. 1. Create development profile 2. Configuration settings 3. Pointing extension to your dev directory 4. Creating folder structure & files 5. Packaging & installing 6. Distributing your add-on
  • 103. Robert Nyman robert@robertnyman.com http://robertnyman.com Images: http://www.learningresources.com/product/teachers/shop+by+category/activity+kits/construction/m--8226- gears--174-+building+set.do http://www.soitenlystooges.com/item.asp?sku=FGSU578 http://www.flickr.com/photos/28791486@N03/2700643931/ http://www.fetasteutgavan.se/blogg/wp/?p=39 http://www.pixabella.com/plugin/tag/red-hearts http://www.woodlands-junior.kent.sch.uk/customs/xmas/calendar/day13.html http://www.intercan.org/coordinator_list.asp