Tue, 26 Feb 08

Tagging my del.icio.us bookmarks with the domain of the URL that I'm bookmarking

28-Apr-2009. This is now a firefox extension hosted at addons.mozilla.org.

I’ve created another firefox extension that builds on the del.icio.us extension. This one finds the domain of the URL you’re bookmarking and adds it as a tag to your bookmark. It’s basically just a copy of my del.icio.us permalinks extension

To install this extension head over to the delicious domain tags google group and visit the installation page (I don’t seem to be able to link directly to it for some reason).

I came across an interesting problem when trying to get both this and the del.icio.us permalinks extension working together. Both of the extensions modify the onload attribute of the add bookmark dialog. When I only had the del.icio.us permalinks extension I was hardcoding the onload attribute to call my function (deliciousPermalinks.addPermalinkTag()) and the original function (yAddBookMark.init()). This approach fell down as soon as I had two extensions trying to modify the onload attribute: I didn’t know which extension would be loaded first and therefore one was always overwriting the other. I’m sure there’s a nice way to do this but I hacked together a noddy initialisation script that finds the existing value of the onload attribute and adds to it with the relevant function.

var yAddBookmarkDialog = document.getElementById('dlg_AddYBookMark');
var yAddBookmarkOnload = yAddBookmarkDialog.getAttribute('onload');
var onload = 'deliciousPermalinks.addPermalinkTag()';
yAddBookmarkDialog.setAttribute('onload', [yAddBookmarkOnload, onload].join(';'))

I reference this script in my xul file which causes it to be evaluated at (I guess) browser start time and the onload event to be modified correctly.

I’ve updated the del.icio.us permalinks extension too but I think you’ll need to remove and re-add it again from the installation page.