roachfiend.com

  • firefox extensions
  • tutorials
  • faq
  • December 8, 2004

    How to create Firefox extensions

    Filed under: tutorials — Eric @ 6:47 pm

    Everyone has a good idea at one time or another to implement a new feature in a web browser. Well, with the goodness that is Mozilla Firefox, now you can do just that. You need to have a vague understanding of XUL and Javascript, but you certainly don’t need to be a master of either. When I started, I knew nothing about either one, really. I had seen some bookmarklets here and there, and tried to figure out just how they worked. Well, that’s how I made my first extension, BugMeNot.

    Contents

    1. Learn By Example
    2. Hello, world!
    3. Looking inside the XPI
    4. Re-configuring your extension’s installation
    5. Chrome is more than a shiny bumper
    6. Skin that cat
    7. Pack it up and try it out
    8. An easier way to re-build
    9. My Firefox got completely hosed up
    10. Ensure server compatibility
    11. Additonal help and information
    12. Comments / Feedback

    Learn by example

    Everyone has a good idea at one time or another to implement a new feature in a web browser. Well, with the goodness that is Mozilla Firefox, now you can do just that. You need to have a vague understanding of XUL and Javascript, but you certainly don’t need to be a master of either. When I started, I knew nothing about either one, really. I had seen some bookmarklets here and there, and tried to figure out just how they worked. Well, that’s how I made my first extension, BugMeNot.

    Basically, this tutorial will show you how to create your first extension from scratch. Since every programmer always learns from the famous “Hello, world!” example, I figured that would be a good way to introduce you to developing extensions.

    Xul Planet has a nice little tutorial which will show you the basics of creating a menu. Mozilla also has a very handy DOM Window Interface reference if you’d like to take a look through that. They’re both geared toward an audience that has a good feel for programming, though, so it’s not necessary to understand everything going on to follow this tutorial.



    Hello, world!

    Our extension will be a nice simple one that will pop up a window proclaiming “Hello, world!” after we select it either in a right-click menu, or under the Tools menu. Both of these places are very popular positions, and it’s relatively easy to stick something in there.

    Let’s see what the end result looks like, so you know what to expect. First, here are the two ways to access our extension:

    Right-clicking will get us this:

    Right-click screenshot

    The tools menu looks like this:

    Tools menu screenshot

    The end result of our extension’s efforts:

    Alert screenshot

    What it looks like in the extension manager:

    Extension manager screenshot

    Clicking on the “About…” in the extension manager will get us this:

    About... screenshot

    Looking inside the XPI

    Here’s how the extension breaks down in a nutshell, using a pre-made Hello, world! extension as an example:

    (You can download it here, just right-click and save, then you can follow along.)

    helloworld.xpi is the packaged extension. XPI is just an file format that your browser will recognize as a browser extension. In reality, it’s just a zipped up file. So you can rename the XPI to ZIP or even JAR if you want, then open it up using an archive program, like 7-Zip or WinRAR. So, once that’s opened up, you’ll see:

    • chrome
    • install.js
    • install.rdf

    A folder and two files. install.js was all you used to need for the installation, but now that the extension manager has changed (since Firefox 0.9), the install.rdf is used instead. Now, the install.js is used purely for earlier versions of Firefox/bird, Mozilla, and Netscape. If you want to make this extension solely for 0.9+ versions of Firefox, then you can omit this file if you’d like. I tend to keep it in because it only take a second to make, and assures a wide audience compatibility. Some extensions simply aren’t backwards-compatible, though, for example my ListZilla extension, since it gathers all information from 0.9’s extensions manager. A nice simple “Hello, world!” prompt shouldn’t present any problems, though.

    If you open up install.js, you’ll see that it’s very basic, in terms of what you need to modify to make your own install script:

    // --- Editable items begin ---
    extFullName: 'Hello, world!', // The name displayed to the user
    extShortName: 'helloworld', // The leafname of the JAR file 
    extVersion: '0.1',
    extAuthor: 'Eric Hamiter',
    extLocaleNames: null, // e.g. ['en-US', 'en-GB']
    extSkinNames: null, // e.g. ['classic', 'modern']
    extPostInstallMessage: 'Success! Please restart your browser to finish the 
    installation.'
    // Set to null for no post-install message
    // --- Editable items end ---
    

    So all the hard work is done for you. I’m not going post the rest of the code, but you’ll see quite a lengthy amount of work that is fully automated.

    Now if you open install.rdf. you’ll see this:

    <?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>{9AA46F4F-4DC7-4c06-97AF-5035170633FE}</em:id>
            <em:name>Hello, world!</em:name>
            <em:version>0.1</em:version>
            <em:description>Displays an alert message via right-click
            or Tools menu.</em:description>
            <em:creator>Eric Hamiter</em:creator>
            <em:homepageURL>http://extensions.roachfiend.com</em:homepageURL>
            <em:iconURL>chrome://helloworld/skin/helloworld.png</em:iconURL>
            <em:aboutURL>chrome://helloworld/content/about.xul</em:aboutURL>
            <em:file>
                <Description about="urn:mozilla:extension:file:helloworld.jar">
                    <em:package>content/helloworld/</em:package>
                    <em:skin>skin/classic/helloworld/</em:skin>
                </Description>
            </em:file>
    
            <em:targetApplication>
                <Description>
                    <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
                    <em:minVersion>0.7</em:minVersion>
                    <em:maxVersion>9.9</em:maxVersion>
                </Description>
            </em:targetApplication>
    
        </Description>
    
    </RDF>
    



    Re-configuring your extension’s installation

    Ok, whoa.. what is all this crap? The first thing you’ll see is the <em:id> tag. This is your very own generated id that will separate your extension from anyone else’s. There are a few ways to make it. You can either use an online perl script to randomly generate one, or if you use Windows, you can use a program called guidgen, brought to us by Microsoft. How deliciously ironic. Or am I misuing the term irony here? Whatever. So if you download that, then you’ll see this when you run it:

    GUIID Screenshot

    So choose 4. Registry Format, then hit New GUID a few times for good measure, then Copy. That’s it, now your new spiffy id is in your clipboard. Replace the old one with this, and you’re set.

    Name, version, description, creator, and homepageURL are all self-explanatory. The iconURL and aboutURL are what shows up if someone right-clicks your extension and chooses “About Extension…”. You can leave these blank, it’s not mandatory, but it’s nice to have a little flash every now and then.

    Underneath file, this is standard stuff. Just replace all instances of “helloworld” with your extension name. This is where the installation will try and find your files and folders. If you have any icons, you’ll include the skin folder. Again, it’s not mandatory.

    Target application is what you’re gearing this for. The ec8030f7… is unique to Firefox, so leave that alone. The minversion and maxversion is what versions of Firefox it will be compatible with. There was a big stink about this recently, since the developers introduced 0.9.1, shortly after telling us to make sure and only put a maxVersion of 0.9. This does not compute. So I recently modified mine to go to 9.9, which will ensure compatibility through the next few versions of Firefox. This isn’t the type of thing that mozilla will support, since they can only recommend keeping the maxVersion to the current release, but it’s the best way to keep you sane, so you don’t have to update your extensions every few weeeks.



    Chrome is more than a shiny bumper

    Ok, now open up the chrome folder. In there you’ll find another archived file, helloworld.jar. Open it up and extract the files. You’ll now have content and skin folders. Let’s explore content first. In there, we have a helloworld folder, and under that, these files:

    • about.xul
    • contents.rdf
    • helloworldOverlay.js
    • helloworldOverlay.xul

    about.xul is the file you see when you click “About Hello, world!…” in the extensions menu. It’s pretty self-explanatory, and you’ll see that a nice man named Jed Brown wrote the template for it, so all the hard work has been done for you. Again. So just fill out the info, and that’s it.

    helloworldOverlay.xul and helloworldOverlay.js are what make things happen. They’re the brains behind the outfit, so to speak. And you’ll be amazed at how simple they are. Here’s helloworldOverlay.xul:

    <?xml version="1.0"?>
    
    <overlay id="helloworldOverlay"
             xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    
    <!-- This imports our javascript. -->
    
    <script type="application/x-javascript" 
    src="chrome://helloworld/content/helloworldOverlay.js">
    
    </script>
    
    
    <!-- This is for the right click menu. -->
    
    <popup id="contentAreaContextMenu">
      <menuitem id="helloworld" label="Hello, world!" accesskey="H"
      insertafter="context-stop" oncommand="hello();"/>
    </popup>
    
    
    <!-- This is for the Tools menu. -->
    
    <menupopup id="menu_ToolsPopup">
        <menuitem insertafter="devToolsSeparator" label="Hello, world!"
        accesskey="H" oncommand="hello();" />
    </menupopup>
    
    
    </overlay>
    

    So all it says to do is to insert the javascript file, helloworldOverlay.js, and to create a context menu entry called Hello, world! accesskey=”H” underlines the “H”, since it’s the first letter that wasn’t taken by any other options. insertafter=”context-stop” places the option directly underneath the Stop label. oncommand makes it launch the window with the function hello, which is located in the javascript file we imported earlier. The second part of the overlay tells it we also want to place an option in the Tools menu. Same logic as the context menu, just a different place to stick it. Here’s what helloworldOverlay.js looks like:

    // This is our javascript, which will pop up our message
    // in an alert box.
    
    function hello(){
        alert("Hello, world!");
    }
    

    Now for contents.rdf. This is the file that tells the browser where to store this overlay information. Here’s what it looks like:

    <?xml version="1.0"?>
    
    <RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
    
        <RDF:Seq RDF:about="urn:mozilla:package:root">
            <RDF:li RDF:resource="urn:mozilla:package:helloworld"/>
        </RDF:Seq>
    
        <RDF:Seq RDF:about="urn:mozilla:overlays">
            <RDF:li RDF:resource="chrome://browser/content/browser.xul"/>
            <RDF:li RDF:resource="chrome://navigator/content/navigator.xul"/>
        </RDF:Seq>
    
        <RDF:Seq RDF:about="chrome://browser/content/browser.xul">
            <RDF:li>chrome://helloworld/content/helloworldOverlay.xul</RDF:li>
        </RDF:Seq>
    
        <RDF:Seq about="chrome://navigator/content/navigator.xul">
            <RDF:li>chrome://helloworld/content/helloworldOverlay.xul</RDF:li>
        </RDF:Seq>
    
        <RDF:Description RDF:about="urn:mozilla:package:helloworld"
            chrome:displayName="Hello, world! 0.1"
            chrome:author="Eric Hamiter"
            chrome:authorURL="mailto:ehamiter@gmail.com"
            chrome:name="helloworld"
            chrome:extension="true"
            chrome:description="Displays an alert message via right-click
            or Tools menu.">
        </RDF:Description>
    
    </RDF:RDF>
    

    You’ll notice the address chrome://browser/content/browser.xul up there. This is mozilla’s internal frame of reference. browser is the actual browser, and navigator works for non-Firefox builds, like Netscape or Mozilla. The only part you’d need to modify is the descriptions. The rest of it just implements the extension into the browsers.



    Skin that cat

    Now let’s backtrack to the skin folder. In it, we’ll find a few more folders: classic and helloworld. This is just the traditional layout, and if it ain’t broke, then hey, don’t fix it. In helloworld, we find three files: helloworld.png, helloworldb.png, and a contents.rdf file.

    helloworld.png:

    Hello, world! small icon

    helloworldb.png:

    Hello, world! large icon

    These are called from about.xul mentioned previously, for use in the extension menu and the about menu. contents.rdf simply maps out the paths to the skin files, so the only modification you need to change for your own extension is in the last line, which points to the folder helloworld.



    Pack it up and try it out

    So now that you see how the files work, and where they’re packaged, you can modify them to your whims, and try out new things. Once you modify them, just pack them up in reverse order. Using your archive program, you would navigate back up to the chrome folder, and add content and skin into a zipped archive, then rename it to extension.jar. After that, navigate up another folder, and add chrome, install.rdf, and install.js into another zipped archive, then rename it to extension.xpi.

    You’re ready to test it out in your browser now. Open up Firefox, and hit CTRL-O, or Open File. Load up your xpi file, and say yes to the installation. Restart Firefox, and hopefully you’ll see your new extension in the menu, and it does whatever you had hoped it would do.



    An easier way to re-build

    After a while, it gets tiresome to select your files, your folder, archive them, rename them, move them, delete them, rename them… you get my point. If you have 7-Zip installed, you can use the command line feature, so you can have this all fully automated. Here’s what you need to do:

    Copy C:\Program Files\7-Zip\7z.exe to C:\WINDOWS\system32 (This will put 7z.exe in your system’s path, which will make it accessible from the command prompt).

    It’s a good practice to build your extensions somewhere far away from random scripts and clutter, so create a new folder somewhere and call it whatever your extension is named. Make sure it matches the internal .jar file that you previously referenced in your install.rdf file. You can always rename the final xpi to something more intricate afterward, but for packaging, it’s best to keep it simple.

    Copy the following script and paste it in a text editor and save it as build.bat in your newly-made folder:

    set x=%cd%
    md build\chrome
    cd chrome
    7z a -tzip "%x%.jar" * -r -mx=0
    move "%x%.jar" ..\build\chrome
    cd ..
    copy install.* build
    cd build
    7z a -tzip "%x%.xpi" * -r -mx=9
    move "%x%.xpi" ..\
    cd ..
    rd build /s/q
    

    Now, you can build or modify your extensions easily. Just use the new folder as your base of creation, so that would contain the install files and chrome folder. Whenever you want to create your new file, just double-click build.bat, and your new extension will pop out in the same folder. Each time you use the build.bat script, it will delete your old file and create a new one.



    My Firefox just got completely hosed up

    Worst case scenario: upon restarting Firefox, it hangs with a “Firefox is still installing an extension, this may take a minute…”. This means you borked it up somehow. Don’t panic! A super easy way of uninstalling it without hosing the rest of your shit up is as follows:

    Start » Program Files » Mozilla Firefox » Mozilla Firefox (Safe Mode)

    Then go to Tools » Extensions » [right-click on your extension] » Uninstall

    Restart Firefox, and it’ll be gone. Then modify your files and try again.



    Ensure server compatibility

    If it works, and you want to put it on your web server, but find out that it won’t install directly, and your browser is treating it as “Save File As..” then you need to modify your .htaccess file. You can learn more about it here, but for brevity’s sake, you need your server to run on Apache for it to work. If you have no problem modifying the file, here’s the information you need to add:

    Add this to your .htaccess file:

    AddType application/x-xpinstall xpi

    And you should be set.



    Additional help and information

    If you want to take a look at any other files I’ve created, they’re on my main extensions page, and I’ll list them directly here for convenience as well:

    If you’d like to put a certain snippet of Javascript on every page, Allow Right-Click or Always Remember Password is the way to go. Alt-Text for Links uses javascript to control tooltips. If you’d like to create your own links menu, then Goon Menu is good to learn from. BugMeNot uses complex regular expressions, ListZilla deals with setting options and using the extension manager, and WordCount is a good way to learn how to take a bookmarklet and use it as an extension.

    The Mozillazine extensions forum is a great place to learn more about creating extensions. They’re under heavy loads from time to time, so they might be down when you read this, but try back again if they are, because they have a lot of useful information there.

    Loads of other useful extensions can also be found at Mozilla Update, and there’s another place called My Extensions Mirror that has forums as well as tons of extensions.

    Well, that’s it. Hopefully this has been helpful to at least a few ambitious people, as well as a look into what goes into making one for the non-technical types. So get off your ass and make something useful!




    -->

    260 Responses to “How to create Firefox extensions”

    1. creaza Says:

      Hi!

      you are inspiring others to write tutorials. way to go! and i quote

      ‘Heavily inspired by roachfiend.com’

      http://www.gmacker.com/web/content/tutorial/firefox/firefoxtutorial.htm

    2. Ilan Says:

      Hi,
      Thanks for a great tutorial. Helped me a lot.

      Can you re-post you tutorial about updating extensions, or point to where I can find info about it?

      Thanks.

    3. Eric Says:


      Ilan, I’ll probably end up re-writing that tutorial today, so check back soon.

      Edit: it’s up now.


    4. Ilan Says:

      Thanks for the quick response :)

    5. Chad L Says:

      Thanks for the great tutorial!

    6. Raik Says:

      hi!
      i have advanced the build.bat :
      http://kb.mozillazine.org/Talk:Dev:Extensions:Windowscmdbuild_script
      now it works too in subdirectories with the pure foldername, stripped from path (%CD%).

    7. iacchi Says:

      You shouldn’t write such a kind of guides if you can’t even add a locale to your extensions.

    8. Eric Says:


      Feel free not to read it, then.


    9. trainee Says:

      Nice guide man. Just give me a bit to think of what I want to write an extension for, :).

    10. trevelyan Says:

      Thank you for taking the time to write this. I found it useful.

    11. alexvir Says:

      Hello!

      I need to write a FireFox extension.
      The extension must have an access to DOM of each opened document (am I wright, that each opened document must have one copy of my extension “object”?).
      I’ll try to describe my problem:

      I have standalone application, which keeps the logins & passwords in it’s database. The purpose of FireFox extension is autofill the web-form with specified login & password.

      So when user select any login & password, my application fill the file-mapping structure with selected login & password & send the certain message to FireFox window (for example WM_USER + 13).

      The FireFox window must get login & password from file-mapping stucture & autofill the web-form of current document.

      On initialization extension must set hook to current FireFox window. If certain message will be received by hook, extension must fill the web-form with login and password (wich it get from file-mapping from standalone application).

      How can I realize this functionality in extension for FireFox? May be you have any samples or code?

      I will very appritiate for any help!!!

    12. Raghu Says:

      Awesome man! This guide is crisp and clear and is a good start for beginners who want to implement their own extensions to FF. Thanks for writing this up.

    13. Josh Says:

      Great tutorial! I want to make a plugin for something at work but I’ll need to put 2 input boxes into the toolbar, do you know of any examples I could follow? I guess it would be similiar to the google toolbar because it will be posting to an internal app.

    14. eg. » Blog Archive » Firefox Extensions Says:

      […] fox Extensions Want to learn how to make your own Firefox extensions. Here is a cool tutorial from RoachFiend.com. T […]

    15. Alan Beaman Says:

      I’m interested in extending Mozilla more than Firefox, but still this tutorial really is great. I thank you very much for sharing it. I second what Raghu said. I’m well on my way to making an extension of my own thanks to you.

    16. Leo Kent » Creating Firefox Extension Says:

      […] iter has written a tutorial showing you how to write a simple “Hello World” extension. http://roachfiend.com/archives/2004/12/08/how-to-create-firefox-extensions/ Comments » The URI to Tra […]

    17. Muhammad Ali Says:

      Hi,

      Great tutorial…
      The last time ( an year ago ) when i tried following a tutorial for making a simple extension, it took me a couple of days, doing everything by hand. It was hell, really.

      This time, it was 15 minutes…
      Thanks again :)

    18. Manish G Says:

      Excellent tutorial! I’m wondering if you can write extensions for firefox running on linux/bsd, as well. Any thought?

      thanks for sharing the tutorials :)

    19. TechSmoke » » How to create Firefox extensions Says:

      […] ow to create Firefox extensions
      Filed under: ramblings — mike @ 4:46 pm
      roachfiend.com » How to create Firefox extensions Thought this migh […]

    20. Jennifer Says:

      Could you post (or direct me to) newb directions on using the command line feature to zip everything up?

    21. Chris Says:

      Thank you! You rock.

    22. Zaeem Says:

      Cool tutorial! Thanks for making it easy. I just want to do a few extensions for my own use and this is sufficient to get me going.

    23. 925 » Create a FF extension yourself Says:

      […] Create a FF extension yourself
      How to create Firefox extensions
      …this tutorial is just so cool, […]

    24. Ali (Saudi Arabia) Says:

      Many Many Thanks for the toturial …
      It was easy to follow and clear enough..
      I started to think about making an extension after I read it ..

      Thank you again ..

    25. Nobo Says:

      Great tutorial! But I’ve a problem, when I open the xpi file in firefox and on install now click:

      Firefox could no download the file at [uri] because: Install script not found

      I use linux, this is the reason. Firefox can’t read the zip file correctly. I don’t know how I should create the zip file Can someone help me?

    26. someuser77 Says:

      why do i get a update available notice after i remove all update urls from this extansion?

    27. EgoBurp » Web Annotation II – The Hacking Says:

      […] 7;t too painful, though. Then it came time to modify the wikalong extension. I found the roachfiend site on Firefox extension development. I don’t blam […]

    28. Tearfang Says:

      Cool tutorial, but I have this one problem with it, you mention that “Clicking on the “About…? in the extension manager will get us this” I’m looking at your picture of the extention manager above… (and the window that pops up when I got tools->extensions) and I don’t see an about button… perhaps I’m just stupid, but I don’t seem to be able to figure out how to get the about window you show to pop up.

    29. Eric Says:


      Tearfang, try right-clicking on an extension in the extension manager. Then you’ll see the about option.


    30. Dirk Says:

      Cool tutorial!
      Can you recpmmend some pages handling JS for firefox plugins?

    31. kinan al jajeh Says:

      Thanks a lot.

    32. Gavin Says:

      Thanks for the excellent tutorial, it has been extremely informative, not to mention concise.

      Thanks again!

    33. Harmen van Rossum Says:

      If you plan to make the extension available for linux don’t use the guid provided by the perl-script, it won’t work! (It took me some hours to figure that out). I think the reason is that your GUID does not contain any capital characters.

    34. Harmen van Rossum Says:

      Sorry I think something else went wrong. Thank you for this excellent guide.

    35. Jason Harms Says:

      Is this tutorial similar to what you would need to create a Thunderbird extension as well? Great tutorial. Thanks.

    36. Jennifer Says:

      Hi,

      thanks for this!

      It would be EXTREMELY helpful to extension newbs like myself if you would include that package names(in chrome/contents/extension_name/contents.rdf) MUST be lowercase. NO MIXED CASE!

      Spent way too much time trying to figure out why my extension wouldn’t install, and worse, why it would disable my browser - until I came accross this juicy little tidbit.

    37. jr Says:

      you made bugMeNot?

      omg - you rock!
      thanks!

    38. leaf Says:

      that great thanks

    39. Ed Says:

      Excellent Tutorial! Many thanks. Think I now get an idea what the hell is going on with extensions.

    40. Brendan Says:

      Great Tutorial and nice extensions. VERY helpful.

    41. jIm Says:

      Could you write a tutorial on how to make your extension’s command show up in the “This Frame” sub menu?

    42. tireetoo Says:

      I never knew about that thing either! That tells me a lot.

    43. David Grice Says:

      SPOCK - “Captain! We should identify the species first then select a language to communicate!”

      CAPTAIN KIRK - “Mr. Spock. Are you saying that this is a new species?”

      SPOCK - “No Captain! Just unidentified.”

      ……………………………..

      I enjoyed the tutorial. It was not on my list of goals. This was a delightful distraction from my endeavors. Upon the conclusion, I pondered the thought of how I surfed over to the other side of CYBERSPACE UNIVERSE and confronted by this alien topic.

      I for unknown reason I will probably always remember this tutorial when all my other memories become mush!

      I blew the time in this tutorial in nothing flat. I glanced at the time and warped 1.5 hours into the future without a good excuse for the lost time. It was then I recalled a comparative anomally from a forgotten TV episode space exploration series.
      WITHOUT HESITATION I ADMIT THAT A GOOD TRAINING PROGRAM/INSTRUCTOR AND OR TUTORIAL THAT CONSUMS THE STUDENT’S/READER’S/AUDIENCE’S THOUGHT, TIME, FOCUS, AND ATTENTION, IS WRITTEN WELL. WHATEVER THE SUBJECT MATTER/LANGUAGE MIGHT BE!!!!!

      David Grice Orlando

    44. Eric Says:


      Well thanks, David… I think.


    45. Eduardo Says:

      I didn´t work here. Firefox 1.0.4 won´t install it here. It says: “install-ibf.rdl” and other files are malformed !

    46. NSK Says:

      What a great tutorial! You are really good at writing tutorials! Keep up your good work!

    47. Mark Maclane Says:

      Hello,

      This tutorial is very helpfull. Thanks for that.

      Where can we find other tutorials about firefox extensions ?

    48. Pete Says:

      What is the date on this tutorial? According to “Writing Firefox/Thunderbird Extensions” by Ben Goodger (05/02/2004), the installation file should be “.rdf”, not “install.rdf”.

      Which is correct (or are they both acceptable)?

      Thanks for a great tutorial!

    49. Robert Says:

      I had the same problem ‘NOBO’ reported on Linux.

      Firefox could no download the file at [uri] because: Install script not found

      The solution is to re-zip the file correctly.

      In my broken zipfile, items listed out with a preceding period. e.g “./chrome”. This was created by ‘jar’ In the fixed version, they are not: “chrome/”. This fixed zip was from ‘zip’

    50. Kryptech Says:

      Its great that people like you are supporting open source and free coding like this. Good job.

    51. Same Old Shit :: Link of the day :: June :: 2005 Says:

      […] ybe I’ll make up for it and you’ll get two links today. For now you can learn roachfiend.com » how to create Firefox extensions. Enjoy.
      Brad 2: […]

    52. Rob Says:

      This tutorial rocks!

    53. Mark Berman Says:

      Thanks a lot for the tutorial. I love firefox.

    54. pile0nades Says:

      Thanks for the tutorial. I am trying to write a firefox extension and this is a big help.

    55. ELIJAH Says:

      Hey.. Great tutorial!

      How do you make a dialog come up when the user presses the “Options” button from the Extensions window?

    56. voidmachine Says:

      I’ve modified and rewrittend some parts of the example to get it to work with Thunderbird (1.0.2).

      Hello Thunderbird - Extension: http://voidmachine.org

    57. Leo Dopson Says:

      Nice tutorial…
      something weird happend to my build.bat “\par” was pasted on every line, not sure how that happened…

      Keep an eye out for that.

    58. crimsonlink.com . Says:

      Hey If you study my logs, I’ve been getting random requests from Googlebot, It’s always in the root or in relevant subdirectories (usually /blog and forum or similar). All of these sites are with Word Press, and I can promise there is no mention of or links or anywhere. This means Googlebot is guessing that these files will be there. Now I’ve come to expect random flailing for syndication files from Feedster and Kinja, but Google? Et tu, Googlebot? Google pr updation is neer by in this month, so get your way……..

    59. tz Says:

      Grat Tutorial!!
      Thanks a lot!

    60. Devsyn Web Crafting Services » Blog Archive » How to Create Firefox Extensions Says:

      […] te Firefox Extensions
      Eric of roachfiend.com has two helpful tutorials up on How to Create Firefox Extensions and Enabling Extension Updates. These […]

    61. Miksago Says:

      G’day i followed the tutorial but just a it was installing it said”sorry Extension not compatible”
      Whats wrong?

    62. MaaSTaaR Says:

      Great information ! :-)

    63. auto transport Says:

      Realy great tutorial.

    64. thoughtsignals - a blog about media, technology, productivity, etc. Says:

      […] fox extensions. Maybe if I can find some free time I’ll take a crack at making one. Link. […]

    65. TheSnyda Says:

      Thank you for taking the time to make this tutorial. I however, cannot open the “helloworld.jar” file under the “chrome” subfolder.

      Please help if you can. Thanks.

    66. Peter Barratt Says:

      How do I read/write to/from local files?

      Thanks

    67. Ramiz Says:

      Hey Eric! Mind emailing me :P? I had a question about a small thing related to your tutorial which I can’t seem to work out.. I am totally stuck at a step. Thanks :)

    68. ... Says:

      nice words… very helpful!

    69. Robert Baillie Says:

      Excellent guide. I wish I’d read this before I started on my own extension travels about a week ago!

      I also produced a batch file packager, which you can find
      here

    70. Alex Says:

      Thanks for all the help.
      It helped me to achive writting my own extenstions.

    71. Alex Says:

      Nice tutorial
      Thank you for help

    72. NAME Says:

      It says “Invald XPI install” or something of that sort.

    73. Jacky Kong Says:

      Wonderful. Now I have a better understanding of how an extension is built. Thanks.

    74. Whittnet » Blog Archive » How to create Firefox extensions Says:

      […] ing at a serious level. Thought some people might like to have a look at this article. read more | digg story This entry […]

    75. Eric Says:


      I updated the maxVersion number on this so the latest Firefox release will work.


    76. Kingwood Says:

      Excellent tutorial! Thanks you very much!

    77. Rayor Says:

      Where could I find an API for Firefox extensions?

    78. Rodrigues Says:

      Good article, could the author or someone point out to some article that halps me write a Java extension in Firefox? Basically I want the extension to invoke my java code and execute something.

      Thanks,

      • Rodrigues
    79. Aníbal Says:

      Hi,
      first thank’s by the tutorial and i asking your help if you can.
      I can’t install the extension, it ask to restart the firefox, and to be sure i have restart the pc and cannot see the option Tools->HelloWorld and it says thath i have to restart firefox.
      I have to make a extension for project at university and it’s a good idea if I can do a hello world.
      Thanks,
      Aníbal (Portugal)

    80. Philippe C. Martin Says:

      I just found your tutorial (thank you).

      I have not been thorough yet and might have missed the answer but …

      My question is: can a plugin access a local hardware device, get information from it and return it to the server ?

    81. TD Says:

      Awesome. This is just what people like myself need to create their own extensions for Firefox. Thanks!

    82. XerBlade Says:

      Yo, I was wondering if you could tell me, how do you get a context menu item in an extension to only show up when right-clicking on a link?

    83. Kristina Says:

      Thanks for the tutorial! Very useful.

    84. Eric Says:


      XerBlade:

      function OnlyShowOnLink() {
      var cm = gContextMenu;
      document.getElementById("object") = cm.onLink;
      }


    85. Gerzean Says:

      Hi, hope someone replies to this.

      I wanna make a Quicktime plug-in for Firefox.

      Yes, I know about Quicktime Alternative. But I think I
      could put together an app that leaves an even SMALLER
      footprint than that.

      The Quicktime standalone is 19.2 MB (over 60MB installed). Quicktime ALternative is 10.5MB, but still over 30MB installed.

      I got Media Player Classic and a codec installed on my system. Together, they only take up 6MB!

      Only problem is… NO plug-in.
      Any ideas?

      Please e-mail me at gerzean@gmail.com

    86. Scorpie Says:

      Nice tutorial, i’ve looked at some more tutorials but have run into a problem now: this tutorial explains how you can have an ‘about’ with your extension but it doesn’t cover the ‘options’ form.
      Can anyone link me to a page that explains how to make an options menu for my extension in a way the options will be saved and reloaded next time the extension needs the settings.

      Thanks in advance,

      Scorpie

    87. mstrblstrprdctns Says:

      nice! One question though:
      what are the .DSStore files, and the _MACOSX folder?
      some files mac’s need? how do you create them?

    88. Haider Ali Says:

      Can we Call ANY FIREFOX EXTENSION from Linux Command Line

      I tried SCREENGRAB Extension to Run from Command Line i dont know…ANY Body would like to Share ideas??

    89. saurabh Says:

      I will now write extension in my sem brek

    90. Nando Vieira Says:

      Hello Eric! Great tutorial!

      I did a bat file to automatic create the .xpi extension. You just need to create the directory structure as:

      basedir/packager.bat
      basedir/extensionname
      basedir/extension
      name/chrome
      basedir/extensionname/chrome/extensionname/.

      To create package, run packager.bat and provide the name of your extension.
      It will create all the structure on Windows TMP folder and move the .xpi to the basedir.

      You can download this example and the packager.bat on http://simplesideias.com.br/extension/extension.zip

    91. KC Says:

      Can you make an extension for firefox that can show nfl scores of certain teams of your choice that will be seen either in a tool bar above or down by the status bar?

    92. Muychingon Says:

      Excellent tutorial. even for beginners like me. :)

    93. Abbeey Says:

      Thanks a lot, this tutorial was very useful.

    94. Yuppie Says:

      Very interesting tutorial. Very useful.

    95. Jeff Says:

      Is there a way to make money off writing extensions?

    96. sebastian salas Says:

      I need help for “how to create FireFox Extension” in spanish please, sombody helpme?

    97. Louis Says:

      First of all, thanks for the excellent tutorial!

      My question is, is there any way for an extension to directly edit the preferences of firefox? For example, changing the network settings (pipelining, etc).

      I don’t think directly editing the preferences file will work, because firefox rewrites it when it closes.

      Any help you can give me will be much appreciated.

    98. Nathan Says:

      Greetings one and all,

      And thanks for the tutorial!

      I am not a developer (yet) (unfortunately).

      However, I have a great idea for the aspiring info-preneur (ie firefox extension developer).

      Go check out the (brand new) website:

      http://www.unifiedroot.com/registrars/

      (and No! I don’t work for them; I actually have some gripes).

      The solution/app. should be obvious from that point (go visit the link).

      Someone needs to build a Firefox patch/extension that does this…resolution (and ones like ti) automatically.

      There could eventually be several competing unifiedroots and the one that is the most fair, just and equitable…should/will/can win…

      That is the future of the Web!

      THEN: Firefox users need to develop a “coop” version of what is going on here…. UnifiedRoot has basically just made an unjustified and unfair GRAB of internet real estate that will likely be a) successful (!?)-ish and b) widely (if not wildly) imitated and copied….

      We need to make a forum about this and develop alternatives… UNFORTUNATELY, I don’t have the SKILLS to do this (yet), but I know some of you out there, have both the SKILLS and INTEREST to help sort out this huge profitable (if UNFAIR!) new phenomenon.

      One of my favorite quotes, I think it’s in William Gibson’s “The Princess Bride”:
      “Life isn’t fair. It’s just fairer than death, that’s all.”

      Ain’t it true?

    99. paul Says:

      Instead of using a batch file to recompile the xpi try 7-zip. Its freeware and lets you drill down directly through the xpi and compressed jar, recompiling any changes you make on the fly.

    100. Chadha Software Technologies Says:

      http://www.chadhaajay.net

    101. Bjössi Says:

      Thanks for a great tutorial!

    102. Marko Petkovic Says:

      Good info, thanks. I don’t have time now but I will definetly try to make one, at least Hello world :)

    103. jamestcs Says:

      good info. your tutorial is very clear.

    104. phentermine Says:

      Hi! Nice site. Check site about phentermine - http://phentermine.home.ph

    105. viagra Says:

      Hi! Nice site. Check site about viagra - http://best-meds.test.punkt.pl/viagra/

    106. Ronald Says:

      I think that i easily get this extensions from official & fan’s sites.
      But, i respect thing, what you did!

    107. Shane Says:

      Hey there. I know this is maybe an old thread, but it is still getting lots of attention. I have my extensions development files in a SVN directory. Is there a way for 7z.exe to ignore the “.svn” folder when running the bat files. This adds an extra meg to the .xpi in the end. Thanks in advance. :)

    108. Joshua Says:

      I am just learning how to do this, and I think that I may take up to a week for me to be able to get one right.
      Anyway, my question is - is it possible to extract data from websites? Let’s say I want to extract data or something from a webpage and utilize it in my extension, how would I go about this?

    109. Untold Says:

      Hi, the packaging script you included in this tutorial works great and very fast,
      however i came to the conclusion it does not implement
      directory’s you add under the root directory of the extension directory.
      Like in my case i was in need to add a defaults folder in my .xpi file,
      so i added the following line to make it work.

      “xcopy defaults* builddefaults /s /i”
      

      This includes the default directory and it’s underlying directory’s into the .xpi

      Here’s my version:

      ==================================
      set x=%cd%
      md buildchrome
      cd chrome
      7z a -tzip "%x%.jar" * -r -mx=0
      move "%x%.jar" ..buildchrome
      cd ..
      copy install.* build
      
      REM
      xcopy defaults* builddefaults /s /i
      
      cd build
      7z a -tzip "%x%.xpi" * -r -mx=9
      move "%x%.xpi" ..
      cd ..
      rd build /s/q
      ========================================
      

      Hope this is a help to all you out there facing the same needs :-)

    110. lee Says:

      Great site and you are the only site that told me to change the .htaccess file to:

      AddType application/x-xpinstall xpi

      Thank YOU!

    111. malaysia travel Says:

      Thanks , i am searching for this tutorial long time ago… thanks for sharing

    112. dedenf Says:

      thanks alot men, this tutorial help me alot. Thanx again

    113. AtariBoy Says:

      Thanks very much for the tutorial, i made good use of it, except that i dont know enough javascript yet :)

      I put a link to it on my blog, hope u dont mind

      http://atariboy.wordpress.com/

    114. Tom Says:

      Nice tutorial. I’ve started writing an extension based on what I’ve learned here.

    115. Josh Says:

      Thanks Eric, this looks extremely helpful. But since i’m popping the proverbial cherry here, i’ve got a question. Can i write an extension to open up other program windows into a firefox tab? kind of like the pdf viewer extension?

      What i want to do is write an extension for Isilo document reader so i can have access in firefox

      is that possible at all? for a novice?

      thanks, josh

    116. Rick Says:

      iacchi said,

      “You shouldn’t write such a kind of guides if you can’t even add a locale to your extensions.”

      You shouldn’t post comments like that if you can’t even use proper grammar, you retarded troll.

    117. Josh Says:

      Thats funny . . .i didn’t realize that this was an english paper . . . maybe you’re right, maybe i am a retarded troll . . . .maybe i should drop out of medical school. . . .or maybe i’ll stick with it and keep the 6 figure income. . ..

      thanks though

    118. Paul Says:

      Eric has clearly put time and effort into producing a tutorial for those of us who have a genuine interest in creating FireFox extensions.

      If you really are as intelligent as you claim to be then you could perhaps put your time to better use.

      As you can see from the comments posted so far, most people have been helped and inspired by the tutorial.

      If you believe you can create a more superior tutorial then contribute something useful to the community and do so.

    119. Josh Says:

      Hey Paul,
      My apologies, I honestly didn’t mean to offend anyone. My sole purpose was to mock Rick’s comments about grammar. In no way did I intend to insult anyone else.

      I was thrilled when I saw this tutorial because I would like to learn more about programming.

      If I offended anyone, I apologize. Except for Rick - he’s still a douche

    120. phpkb Knowledge Base Software Says:

      phpkb Knowledge Base Software Script

    121. Josh Says:

      Oh man, I just finished my first extension! I know its just a simple extension but its a neat feeling. I can see thought that i’m a long ways from the extension i want to right!

    122. Phred Says:

      I have an updated helloworld.xpi for firefox 1.5.
      It is more of an application than the original.
      - command line handling
      - chrome.manifest rather than contents.rdf
      - includes locale
      - includes default preferences

      Probably time this tutorial was updated ;-)

    123. Australia Migration Agent Says:

      Good tutorial , thanks for info

      Regards,


      Jam

    124. Kate Says:

      was thrilled when I saw this tutorial because I would like to learn more about programming.

    125. Viper Says:

      Hallo evrybody.. nice place here :) Feel free to visit my website
      http://home.arcor.de/ativan/ativan.html

    126. kltsin Says:

      I have a navigation menu extension but dont know how to add a link in menu.xul that contains the “&” symbol.
      For instance
      &t=33258′);” oncommand=”tsg_ope

      Any help for this?

    127. kltsin Says:

      oopss here it is
      onclick=”mboopen(event, ‘http:// folding.extremeoverclocking.com/userlist.php?s=andsrt=1&t=33258′);” oncomma … etc

    128. bob Says:

      i am making an extenion that is a dropdown menu. i have it all working and fine. but does anyone know how to get it to use an RSS bookmark?

      like a standard live bookmark. i know it can be done. hell, firefoxes ‘go’ dropdown can have those.

      but does anyone know how to define them in an extention? (used as a news update for my site that broadcasts rss)

    129. bob Says:

      and to add links with a & in it. replace the & with this & that will make it work

    130. kltsin Says:

      lol doesnt show up

    131. Catalin Says:

      Awesome!
      Thank you for information!

      Best Regards,

      Catalin

    132. spatiu Says:

      You may use this tool to create a Firefox extension.
      http://www.arantius.com/misc/greasemonkey/script-compiler.php

    133. Malaysia car security Says:

      thanks for your info :)

    134. Alexander Says:

      Hi,
      Nice tutorial.

      Does anyone know if it’s possible to install xpi without user interaction? I’m willing to include my extension to external installation.

    135. Johannes Buchner Says:

      Hey, i released Anti-Paranoia:
      https://addons.mozilla.org/extensions/moreinfo.php?id=2001

      It bases very much on this Hello world example and could be the next step for starters. You can look at the code at http://johbuc6.coconia.net/doku.php/anti-paranoia

      Enjoy!

    136. Someone Says:

      sweet tutorial, too bad it sucks
      -impossible to follow
      -partial codes cause ur a lazy fuck
      -doesnt teach u anything about creating extensions, just tells u how to make the ever so usefull “hello world”

    137. Malaysia pallet manufacturer Says:

      nice tutorial, thanks for info

      jimmy

    138. bulk domain for web hosting reseller Says:

      cool tutorial, thanks for helping.

    139. A Llama Says:

      Someone wrote how the tutorial sucks because it’s…

      “-impossible to follow
      -partial codes…
      - doesn’t teach you about creating…”

      First off the tutorial is one of the best and easiest to follow I’ve found on the net thus far.

      Well since the code is downloadable, it provides all the information.

      It DOES teach you how to create a “Hello World” extension; however, you have to know how to program to make something that you want to make. If you want to make an extension that utilizes javascript-rpc or ajax in order to do some form of database transactions with in your extension, you’ll need to know how to do the javascript for that.

      This was a tutorial for how to make a general extension, and not a tutorial on how to write xul files for chrome. It succeeds very well in it’s purpose.

      Again, a VERY good guide.

    140. penis enlargement Says:

      I agree with you the way you view the issue. I remember Jack London once said everything positive has a negative side; everything negative has positive side. It is also interesting to see different viewpoints & learn useful things in the discussion.

    141. Kris Says:

      This tutorial seems great, but I really want to hone in on creating extensions for Thunderbird.

      Does anyone know of a Thunderbird version of this or a similar tutorial that works on 1.5?

    142. Mase Says:

      Man I got tired scrolling to the last line! HOOOOOF!

    143. Brian Ray Says:

      the roach keeps following me.

    144. singapore car dealer Says:

      cool tutorial, thanks for helping.

    145. Singapore online gift store Says:

      thanks for your info :)

    146. Dusty Wilson Says:

      “Copy C:\Program Files\7-Zip\7z.exe to C:\WINDOWS\system32 (This will put 7z.exe in your system’s path, which will make it accessible from the command prompt).”

      A better way do to this is to add “C:\Program Files\7-Zip\” to your Environment Path. Go to your system control panel or press WIN+BREAK. Click the Advanced tab. Click the Environment Variables button. Under System Variables, find “PATH”, click it, and click Edit. Add it to the end of the path. It should look something like “C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\7-Zip”. Notice the semicolons.

      That way when you update 7-Zip, you don’t have to recopy that binary each time.

    147. chkuya Says:

      Could I translate this page to Chinese, and post it in Mozilla Taiwan Wiki?

    148. singapore cars Says:

      i don’t think the webmaster will answer us… it is in archieves folder

    149. Steve Says:

      Fantastic tutorial! I was looking for a way to add an external language translator (English Spanish) to firefox and this goes a long way to answering the firefox mechanics!

    150. penis enlargement pills Says:

      enlargement pills for penis….This site is about penis enlargement methods:pills,exercises,device,patch,information and news.All for a bigger penis.

    151. sizegenetics Says:

      Finally I got out of sizegenetics, and ambled downstairs to the bathroom. After relieving myself, I turned around to see a sizegenetics hamper. The roommate’s clothing hamper.

    152. penis enlargement Says:

      I immediately began jerking off, thinking of her penis enlargement lovely pussy, and how it’s dry yet heady juices were rubbing against my nose, knowing from experience that penis enlargement the scent would somehow remain there on my face all day.

    153. Replication Guide Says:

      This is amazing! I wish there was an easy way to get this to also work in IE. Oh well, I will keep searching.

    154. Poker Guide Says:

      Does anyone know why this will not register in Firefox 1.5.0.1? I tried changing the install.rdf but still seems to be a problem.

    155. KGC Says:

      Google has an extension that will enable one to type a US cell phone number chose from about 10 major service providers and type a brief message, this message will then be sent as an SMS message to the cell phone. (See http://www.google.com/tools/firefox/sendtophone/index.html)

      It would be great if I could create a simple calendar that will just store some basic dates (something like ReminderFox https://addons.mozilla.org/extensions/moreinfo.php?id=1191&application=firefox), but rather than remind me through a browser message have it send a SMS message to my cell phone using the google-sendtophone extension. (This supposes that I leave my computer on and my browser running, but am not necessarily at my computer.)

      Both extensions exist, how do I take two installed extensions and open them up to learn enough to integrate them and then install them as a single integrated extension?

      Thanks for any ideas.

    156. Term Says:

      I know all it. But big thanks ;)
      Added in bookmark

    157. Sith Says:

      May The Force Be With You!

    158. Malaysia funiture bedroom set Says:

      thanks for the info.
      :P

    159. roger Says:

      great site, thanks

    160. North West Enterpise Sdn Bhd Says:

      great tutorial !

    161. Term Says:

      Repol PHP
      nothing more [url=http://webobzor.h12.ru]php[/url]
      Term asked

    162. china apparel manufacturer Says:

      This is amazing! I wish there was an easy way to get this to also work in IE. :)