(see Update below!)
For a while, I have assigned a keyword to the del.icio.us bookmarklet. I use Sogudi in Safari for this, but the same feature exists in pretty much any other browser. With the default bookmarklet, I had assigned the keyword “dl” to it, so when viewing a web page, I can just press Command-L, type “dl”, press Enter, enter tags, press “Save”, and it saves the bookmark and takes me back to the page.
This trick by Fraser Speirs inspired me to try and improve this technique. I have now slightly modified the bookmarklet so I can enter the tags I want directly after the keyword. This is the content of the bookmark (make sure it’s all in a single line and without spaces):
javascript:location.href='http://del.icio.us/new/zzamboni?v=2&url='
+encodeURIComponent(location.href)+'&title='+
encodeURIComponent(document.title)+'&tags='+
encodeURIComponent('@@@')
The “@@@” is the special string that tells Sogudi to insert there the text typed after the keyword (for Firefox and Mozilla, use “%s” - I’m not sure for Opera). After this is saved, you can type “dl tag1 tag2 tag3″ and the tags field will be pre-filled, you can just press the “save” button.
For automatically posting the URL, without going through the form, you can use this bookmark:
javascript:location.href='http://username:password@del.icio.us/api/posts/add?url='
+encodeURIComponent(location.href)+'&description='
+encodeURIComponent(document.title)+'&tags='+
encodeURIComponent('@@@')
Don’t forget to set your username and password in there. This has the disadvantage of showing you the XML result page instead of sending you back to the page.
I think this should also work with QuickSilver, but for now, when I define a bookmark with the special “\*\*\*” in it and use it as a search in QS, it does not send it to Safari - only if I do “Run Javascript” on it, but then I don’t get to give it the tags. Maybe I’ll keep investigating this, although I’m perfectly happy about doing this from the browser.
Final version
Update: Using this improved bookmarklet as a base, I have a new one: if you provide tags, it will automatically add the URL, but if you don’t, it will take you to the input form. It still will use the selected text, if any, as the extended description (unfortunately this does not work in Safari, as it unselects the text when you move to the location bar - bummer). Here are the bookmarklets:
- For Sogudi (right-click, select “Copy link” and paste into the Sogudi configuration window).
- For Firefox or Mozilla (drag into your bookmarks).
In any case, you have to edit the bookmark and replace the string CHANGEME with your del.icio.us username. Here is the code (for the Firefox version), in case you want to cut and paste (make sure you put it all in a single line):
javascript:u='CHANGEME';t='%s';q=location.href;e = '' +
(window.getSelection ? window.getSelection() : document.getSelection ?
document.getSelection() : document.selection.createRange().text);
p=document.title;window.location.href=(t!='%'+'s')?'http://del.icio.us/'+
u+'?tags='+escape(t)+'&url='+escape(q)+'&description='+
escape(p)+ '&extended=' + escape(e):'http://del.icio.us/'+u+
'?v=2&url='+escape(q)+'&title='+escape(p)+
'&extended='+escape(e);
Thanks to John Resig for the improved code!
