Logging back and forward buttons in Firefox

waltman on 2008-07-31T03:45:05

As promised, here's my extension. First, a disclaimer. Though it's unlikely with something this simple, buggy extensions can mess up your Firefox profile, including your bookmarks, cookies, plugins, preferences, and so on. If you're paranoid, see the Firefox documentation on how to create a development profile.

The first thing you need to do is create a directory for your extension. I put mine in ~/extensions/backlog. In that directory we're going to put 4 files:

  • chrome.manifest
  • install.rdf
  • content/overlay.xul
  • content/overlay.js
chrome.manifest tells Firefox where the files are for the extension. This is right out of the Mozilla documentation.

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

install.rdf tells Firefox meta information about the extension:




  
   
    backlog@viscog.cs.drexel.edu
    Back Log
    1.0
    Add history log entries when hitting back button
    Walt Mankowski
    
    http://kb.mozillazine.org/Getting_started_with_extension_development

    
      
        {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
        3.0
        3.0.*
      
    
    
  


Most of that is boilerplate. The most important field is em:id, because that's how you'll identify it to Firefox later on. Note that it has to be in the form of an email address, though it doesn't actually have to be a valid email address. In this extension it's important that em:minVersion is set to 3.0, since I'm using a Firefox 3.0 feature to do the logging.

content/overlay.xul tells Firefox what part of the browser we want to extend. In the tutorials they do things like add "Hello, world" somewhere in the browser window. Here I want to leave the window itself alone and just add some javascript.