New Del.Icio.Us “Dumbify”/Quote Bookmarklet

I had a Del.Icio.Us bookmarklet — Chris Millward’s “extended del.icio.us post” bookmarklet. This bookmarklet grabs the selected text and posts it to the ‘extended’ field of Del.Icio.us. I use Del.Icio.Us less as a bookmarking system and more as a linklogging system, so I usually try to pick a quote from the page or article to serve as a representative notation. You can see examples of what I mean by this by going to my Del.Icio.Us page (now running speedily on del.icio.us’ new servers).

However, if I’m quoting from something that in and of itself has a quote, that internal quote, grammatically, should have single quotation marks, i.e., if I am blogging this quote:

Every 10 feet or so in Santee Alley, there’s someone standing behind a cardboard box full of discs. Each mumbles the same mantra: “DVD, DVD, DVD, DVD, Estar Guars.”

Then the ‘extended’ field of my del.icio.us entry needs to look like:

“Every 10 feet or so in Santee Alley, there’s someone standing behind a cardboard box full of discs. Each mumbles the same mantra: ‘DVD, DVD, DVD, DVD, Estar Guars.’”

So I needed to figure out how to, within the bookmarklet, scan for double quotation marks and turn them into singles. This was complicated considerably by smart quotes — in fact, that had me butting my head up against a wall for quite some time. (I am not a JavaScript expert, and my Google-fu was doing little good.)

However, in doing so, I found Mark Pilgrim’s “Dumb Quotes” Greasemonkey extension. Greasemonkey is JavaScript, so modification of its code quickly expanded the bookmarklet’s capabilities not only for the requested quote modification, but also to plain-text-ify many other common Unicode symbols, such as copyright symbols, etc.

Here is my finished bookmarklet, first expanded for readability:

javascript:

h=location.href;

t=document.title;

e = “” + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text);

e = e.replace(/”/g, “‘”);

e = e.replace(/\xa0/g, ” “);

e = e.replace(/\xa9/g, “\(c\)”);

e = e.replace(/\xae/g, “\(r\)”);

e = e.replace(/\xb7/g, “*”);

e = e.replace(/\u2018/g, “‘”);

e = e.replace(/\u2019/g, “‘”);

e = e.replace(/\u201c/g, “‘”);

e = e.replace(/\u201d/g, “‘”);

e = e.replace(/\u8220/g, “‘”);

e = e.replace(/\u8221/g, “‘”);

e = e.replace(/\u2026/g, “…”);

e = e.replace(/\u2002/g, ” “);

e = e.replace(/\u2003/g, ” “);

e = e.replace(/\u2009/g, ” “);

e = e.replace(/\u2012/g, “–”);

e = e.replace(/\u2013/g, “–”);

e = e.replace(/\u2014/g, “–”);

e = e.replace(/\u2015/g, “–”);

e = e.replace(/\u2122/g, “\(tm\)”);

if (e!=null) location=”http://del.icio.us/new/USERNAME?jump=close&url=” + encodeURIComponent(h) + “&title=” + encodeURIComponent(t) + “&extended=”" + encodeURIComponent(e).replace(/ /g, “+”) + “”";

void 0

And then here in a handy link.

(You will need to change USERNAME to your del.icio.us username, of course, and I’m not sure if the ‘new/’ prefix is necessary now that del.icio.us has moved to the new servers.)

Edit, 15:54 CDT: Something got snafued with Unicode dashes, but it appears to be solved.

Edit, 01/24/06 20:00 CST: Here’s the Cocoalicious version.

Share:
  • Digg
  • del.icio.us
  • Facebook
  • E-mail this story to a friend!
  • Reddit
  • StumbleUpon
  • TwitThis

Related posts:

  1. Foreclosure Angel Honestly, you think sometimes that humanity is full of the...
  2. How to Watch YouTube While You Work Elsewhere The Lifehacker article here is really lukewarm in terms of...
  3. How to Create a “Quick Bookmark” Keystroke in Firefox I could not find this anywhere on the Internet; as...
  4. Improved Del.Icio.Us Posting Bookmarklet (with Gruber’s Title Case Goodness) For a while, I used the del.icio.us Complete Firefox extension,...
  5. Modern-Day CEO Hero — Japan Airlines’ CEO Share: ...

Related posts brought to you by Yet Another Related Posts Plugin.