del.icio.us tagging using browser keywords

(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:

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!

Advertisements

12 responses to “del.icio.us tagging using browser keywords

  1. Pingback: John Resig

  2. Thanks much for the improved version of improved version of your bookmarklet. 😉

    Works well and makes using del.icio.us much faster and easier.

  3. Having similar problem with the improved version. When typing d tag… Firefox apparently triggers a quick search to digg.com in a new tab even though I don’t have a quicksearch bookmark or search box extension for that site (I have used it). I have Tab Mix Plus extension installed but turned off the new tab from location bar option.

  4. Pingback: HARALD MARTIN STRÖM » Blog Archive » Fast del.icio.us-poster bookmarklet

  5. BillSaysThis: just to ask the obvious, have you defined the “d” keyword for the bookmarklet?

  6. You can use the bookmarklet in AcidSearch (a very powerful add-on for your search bar), as well.

    Just delete the “@@@” from the Sogudi bookmarklet, and split the code right at the point where the first @ was (see below). Open double brackets, {{ at the beginning of the “Prefix URL” part, and close them at the end of the “Suffix URL.” Then, swap CHANGEME with your del.icio.us username, and select a shortcut for it.

    Before:
    javascript:u=’CHANGEME’;t=’@@@’;q=location.href;[cut for brevity]encodeURIComponent(e);

    After:
    Prefix URL:
    {{u=’CHANGEME’;t=’ –don’t close brackets here!

    Suffix URL:
    ‘;q=location.href;[cut for brevity]encodeURIComponent(e);}} –close’em here!

    I hope that was clear enough… 😛

  7. Pingback: yup » Flocker and delicious+bookmarklets

  8. This recently stopped working for me. Any idea why?

  9. Geodog – what stopped working? I just updated the bookmarklet, maybe this will fix it?

  10. Yeah, it just stopped working for me as of this afternoon (it was fine this morning). Whenever I try, I get:

    “A required security token was not received with your form data.” I’m guessing they’re now requiring a password?

  11. britta gustafson

    Here’s an explanation of why this doesn’t work anymore: http://groups.yahoo.com/group/ydn-delicious/message/296

  12. Pingback: del.icio.us tagging using browser keywords « llbbl