3

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?

Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171
humanityANDpeace
  • 4,350
  • 3
  • 37
  • 63
  • This is the solution I was looking for https://blog.mozilla.org/addons/2009/01/28/how-to-develop-a-firefox-extension/ In short I will post the answer to my question here giving the basic instructions on "how to setup the in-place-edit of a firefox-extension" – humanityANDpeace Nov 09 '12 at 15:18

2 Answers2

5

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".

humanityANDpeace
  • 4,350
  • 3
  • 37
  • 63
  • Is it accepted to mark one's own answer as the "solution"? While I definitively think it seems a little arrogant and self-assured, I have to say. I researched the answer (outside stackoverflow universe), and it is indeed allowing the things I was seeking for, when putting the question up – humanityANDpeace Nov 10 '12 at 08:23
  • 1
    Another good resource which also includes some hints how to setup an **inplace-editing** is to be found here [https://developer.mozilla.org/en-US/docs/Setting_up_extension_development_environment](https://developer.mozilla.org/en-US/docs/Setting_up_extension_development_environment) – humanityANDpeace Nov 13 '12 at 05:50
  • 1
    i went to the mozilla link because your instructions werent working for me. i notice at the mozilla link they say to make sure you include a trailing slash on the directory name, something that you have omitted, you also omitted to explicitly mention what directory to put the proxy file in. btw the extension data files dont need to live in the extensions directory, only the proxy file does. *update* doh i put the proxy file in the completely wrong directory. progbably wasnt the trailing slash thing in the end after all. – user280109 Jan 25 '14 at 19:26
  • let me guess :) you put it into the `extensions` directory directly below the `.mozilla` folder instead of the one in `.mozilla/firefox/XXXX.profilename/` folder? I think this might be a common pitfall for the folder name `.mozilla/extensions/`seems to hint its for extensions. Indeed it is something used when firefox or other mozilla software installs xpi extensions or updates them. It is some *temporary staging area thing*. Finally, you managed to setup everything now? – humanityANDpeace Jan 26 '14 at 07:07
  • yep, you got it right hehe :) yes got it working, thank you very much. – user280109 Jan 26 '14 at 10:30
3

Note: this is a shameless self-plug - I am talking about an extension I created myself.

Developing an extension in place is possible but has so many issues (mostly caching of all kinds) that it really isn't a good option. Still, you can simplify your development cycle a lot. For that you need to install the Extension Auto-Installer add-on in your Firefox. Then you can put a batch file (assuming that you are developing on Windows) into your extension directory along the lines of:

zip -r test.xpi * -xi *.bat *.xpi
wget --post-file=test.xpi http://localhost:8888/
del test.xpi

The required command line tools are all preinstalled on Unix-based systems, for Windows you can easily download them: zip, wget.

Then you will only need to run that batch file to update your extension in Firefox. If your extension isn't restartless then Firefox will restart automatically. So this replaces your steps 3 to 6.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
  • Thank you. I develop in linux. Your idea of simplifying and automating the "zip-rename-install of the xpi from the extension's develop folder" is smart. Anyhow I found this https://blog.mozilla.org/addons/2009/01/28/how-to-develop-a-firefox-extension/ article. It details the way to simplify the process further. Indeed it is the "in-place-edit" option I was looking out for here. I already made a reply to my "own" answer but I can only give the instructions after 8hours of wainting (for my "poor" 8 experiece points :) – humanityANDpeace Nov 09 '12 at 15:17
  • @humanityANDpeace: Right, you found the option that I referred to with "has so many issues". I am usually trying to give a useful answer, not always the one that the OP asks for - but good luck with that! – Wladimir Palant Nov 09 '12 at 18:06
  • @ Wladimir: And the answer was very much appreciated, thank you. Indeed - without - the even swifter solution I would very likely develop such a mechanism/automation which you suggested. Still in linux of course. Maybe you can improve your firefox-extension development process further using the inspiration of my answer too? – humanityANDpeace Nov 10 '12 at 08:19
  • I am a little concerned about the extension-auto-installer which is required in the solution you suggest. Will this potentially increase risk...? i.e. for some website "auto-installing" malicous extensions? – humanityANDpeace Nov 10 '12 at 08:20
  • @humanityANDpeace: Extension Auto-Installer only accepts local connections by default... – Wladimir Palant Nov 10 '12 at 22:17