Search code examples
firefoxfirefox-addonedit-in-place

develop a firefox extension in place (not via encoding to xpi first)?


Developing an extension for Mozilla Firefox I wonder if there is an "easier way" to what I do right now. Currently I do:

  1. Create a folder - in which to develop - for example myextension

  2. Inside this folder: Create and Edit the Files (like install.rdf, chrome.manifest, xul files. Basically all the other structure of a Firefox extension (no problem here))

  3. Zip-compress the content of the myextension to a ZIP-file (i.e. named myextension.zip)

  4. Rename myextension.zip to myextension.xpi

  5. Install the xpi-file-firefox-extension then in firefox

  6. Restart Firefox

  7. Test the extention

After each edit to the codebase of the extension I need to undergo the process of 3. zip-compress, 4. Rename, 5. install XPI file to firefox, 6 restart browser.

Of course I could automate some of this but still I wonder if there is another way to develop the firefox extension directly in the running firefox profile folder .

The extensions I know are stored in the Firefox profile folder as: firefox/profile/extensions/nameofextension.xpi

I cannot remember well, but I think that there was a way to have the extension being stored unzipped as a folder there too? This way I would still need to restart after edits but not do all the laboursome zipping-renaming-installing.

Any ideas?


Solution

  • It is possible to setup a directory to "in-place-edit" a firefox extension. By this the effort between editing and testing of the Firefox-extension can be reduced.

    I have found the good explanation on the blog https://blog.mozilla.org/addons/2009/01/28/how-to-develop-a-firefox-extension/

    Here I want to give the principal steps necessary to achieve the "in-place-edit"

    Step 1: You have to find your profile directory of Firefox. For example in Linux this would often be often something like this: ~/.mozilla/firefox/#%#%.default/

    Step 2: Go to this profile directory

    Step 3: If you already have any extensions installed (like for example adblock+ or noscript), then inside this profile directory you will find a folder named extensions. If you do not have yet any additional extension installed, it might be easy to simply install any, only to have the **extensions" folder be setup for you.

    Step 4: In this extensions folder you can create a new directory (let us name it "myextensions_1"), which shall contain the stuff of your plugin. This stuff would be the ordinary things like the install.rdf, chrome.manifest files and the content,skin,locale subdirectories. In effect all the stuff you would normaly zip up to become the XPI file.

    Step 5. Create a file that is equal to the content of the <em:id> tag that you used in your ìnstall.rdf file. So if you used <em:id>myextensionname@author.org</em:id> you need to create a file named myextensionname@author.org. Inside this file you will write the location of the "in-place-edit-extension-folder" we created before. In our example this we would have

    • the file myextensionname@author.org
    • which contains only the text ~/.mozilla/firefox/#%#%.default/extensions/myextensions_1

    Of course the text depends on the location of the folder you use for your plugin.

    If you did all things correctly - and maybe double-checked with the instructions of the link above - you can restart or "newly start" firefox. The browser will ask you if you want to allow the usage of the plugin myextensionname@author.org, which you can conceed.

    Now you can edit in the folder ~/.mozilla/firefox/#%#%.default/extensions/myextensions_1 and need not to worry about zipping-up -> renaming -> installing. You simple restart Firefox and the edits to your extensions code will become available.

    This will allow you swifter and faster developing "in-place".