Kladky
Kladky

Reputation: 81

Firefox Extension File Structure

I'm working on updating a Greasemonkey compiler to package Firefox extensions. I think the original version was for Firefox version 3.6 and Greasemonkey version 0.7.20070607.0, and the source code is on GitHub here. I'm going to be working on my update here.

I'm trying to figure out what the current requirements are for Firefox 9/10 extensions so that I can make sure that I am generating the appropriate file structure.

Does anyone know if the following file structure is the current one:

MyExt/
    chrome/
        chrome/chromeFiles/
            chrome/chromeFiles/content/
                MyExt.js
    defaults/
        defaults/preferences/
            prefs.js
    chrome.manifest
    install.rdf

The original compiler outputs this for a Greasemonkey script that does not modify the browser chrome:

MyExt/
    chrome/
    content/
        MyExt.js
        prefs.js
        compiler.js
        xmlhttprequester.js
    chrome.manifest
    install.rdf

The next step will be to make sure that the Greasemonkey code that the compiler uses is current, but I want to get my output goals clear first.

Upvotes: 4

Views: 532

Answers (1)

Wayne
Wayne

Reputation: 60414

That's a typical/acceptable structure (although most people wouldn't nest content under chromeFiles; chrome/content is sufficient). A typical structure can be found here:

my_extension.xpi:             //Equal to a folder named my_extension/
  /install.rdf                //General information about your extension
  /chrome.manifest            //Registers you content with the Chrome engine
  /chrome/
  /chrome/content/  //Contents of your extension such as XUL and JavaScript files
  /chrome/icons/default/*     //Default Icons of the extension
  /chrome/locale/*            //Building an Extension# Localization
  /defaults/preferences/*.js  //Building an Extension# Defaults Files
  /plugins/*
  /components/*
  /components/cmdline.js

However, note the following:

  • The files under chrome can actually be placed anywhere you want, as long as you register those locations properly in the chrome.manifest

  • Components can also be located anywhere. As with the chrome files, the location must be registered in the manifest.

  • Defaults, on the other hand, must be in the defaults folder:

    Defaults files that you use to seed a user's profile with should be placed in defaults/ under the root of your extension's folder hierarchy. Default preferences .js files should be stored in defaults/preferences/ - when you place them here they will be automatically loaded by Firefox's preferences system when it starts so that you can access them using the Preferences API.

  • Both install.rdf and chrome.manifest should reside in the top-level directory of the extension

Upvotes: 3

Related Questions