Firefox Extensions, Digital Open Heart Surgery and XUL Hacking

Dec
21
2005

The Performancing folks released a new Firefox extension Tuesday that makes it easy to post to your Wordpress site (or many other services). However, as always, if you just wanted that announcement, you could go to any one of the hundreds of other sites that made that the extent of their posting. I figured I'd take this opportunity to show you how you can modify a Firefox extension in place before installing it. You can download the .xpi file, dig through it, make changes and the file will be modified for you to then install. I use this on occasion to remove irritating features and that's what I used it for this time too.

The tool works nicely for an early release. Just hit F8 and you get an editing pane at the bottom of the screen to create a post. It stores the list of sites in an XML file, making it easy to transport (important for me and my roving working life). However, it also adds some functionality to the right-click menu and puts it's link right at the top.

I'm not alone in being irritated by this, but I figured I'd just inject the necessary change into the extension and reinstall it. Now, my installation is actually missing the entry entirely, but I'll show you how to just let it fall into the bottom/middle of the list.

First, you're going to need Firefox, 7Zip and the MR Tech Local Install extension to get through much of this, but I'd recommend having these 3 on any workstation anyway.

Once all of that is installed, download the XPI from Performancing (no link because linkrot is pretty likely). Right click it and "Open with". You'll have to choose the program. Navigate to the 7Zip file manager (C:\Program Files\7-Zip\7zFM.exe on my machine). Don't select to always open with this unless you never want to easily install extensions directly from Windows Explorer. It will get put on the menu for next time's easy access though, so it's no big deal.

What you'll get is the 7Zip file manager. If you drill down to the directory with all of the .js and .xul files, you'll be staring at the guts of the extension itself. That path, relative to the .xpi is: \performancing.xpi\chrome\performancing.jar\content\

It's also worth looking around at the rest of the files when you get a chance. The top directory has the install.rdf which often contains the problem you'll be fixing. The rest is the same mind-numbing structure of all XUL packages (currently it's biggest barrier of adoption, but that's for another day).

Anyway, in the content directory, you'll see that it's just a bunch of XUL files (XML user interface files that look a lot like HTML) and Javascript files (that do the behavior). The offending menu item is in overlay.xul. Click it and hit F4, which is the "edit" shortcut key. Go down to about line 66 and you'll see a chunk of code like this:

<popup id="contentAreaContextMenu" >
<menu id="context-performancing" position="1" label="Performancing" class="menuitem-iconic menu-iconic .icon-performancing" accesskey="P" >
<menupopup>
<menuitem id="performancing-cm-blogthis" insertafter="context-sep-properties"
class="menuitem-iconic menu-iconic"
label="Blog this page (in Split Browser)"
accesskey="B"
hidden = "false"
oncommand="performancingUI.blogThis()"/>
</menupopup>
</menu>
</popup>

The bit we're interested in is position="1". If we just cut it out altogether, it will drop the menu item in at the bottom of the regular items (below "View Source", but above other extension-added items like Web Developer). There are lots of other options like putting it in before or after a specific item, etc., but those are beyond the scope of this article. Once you cut out that attribute, save the file and close your editor (this is important because 7Zip looks for the editor to close). 7Zip should now prompt you that the .xul file changed and ask if you want to update. You do.

Now, there's a tiny "up" icon next to the current path in 7Zip. Click it to go back up the tree. When you go past the barrier of performancing.jar, you'll be asked to commit the save again. This is because the .xpi is actually a series of nested ZIP files. We've just edited a file 2 ZIP files in. Go up the tree until you get back to the .xpi, confirming all of the saves on your way up and close 7Zip.

The .xpi file now is your modified version. Install it as usual.

I mention the Local Install extension because it gives you a quick "restart firefox" link as well as lots of other useful stuff if you're going to do much of this kind of thing. Good luck.

 

Comments on this post

Feedback is always welcome. Read some from other folks or leave your own below. Just keep things civil and remember that what you post lives on in public. Forever.

Thanks,
J

Leave Your Own Comment

By submitting a comment, you agree to license it under the terms of the Creative Commons Attribution license.

People who post comments get the added benefit of visiting the site without advertising.

© 2003-2009 J Wynia. All original content is licensed under the terms of the Creative Commons Attribution license unless otherwise noted. Content from other sources is licensed under its original terms.