2009/01/05

VoodooPad Bookmarklets

VoodooPad bookmarklets make it easy to log search results.

I keep a worklog in VoodooPad. Notes for each day are stored in a page with a name of the form 'yyyy-mm-dd'.

When I'm searching for info on the web, I like to include relevant results in my worklog. I tend to record results in this format, to make it easier to find the results again in future:

http://url.of.interest/:
"""
Excerpt
"""


It's tedious to format these excerpts. At least two visits to the browser application are needed:
  1. Copy the URL
  2. Copy the text of interest


Luckily VoodooPad supports application-specific URLs, and you can create JavaScript bookmarklets to open such a URL, with the URL and any selected text for the page you're currently viewing.

Here's an almost human-readable example of a bookmarklet which adds an excerpt from the current web page, formatted as above, to the current worklog page in VoodooPad.

javascript:
var d = new Date();
var padded = function(v) {
var res = v.toString();
while (res.length < 2) {
res = '0' + res;
}
return res;
};
var page = [
String(d.getFullYear()),
padded(d.getMonth() + 1),
padded(d.getDate())
].join("-");
location.href = ('voodoopad:description=' +
encodeURIComponent(location.href + '\n"""\n' +
window.getSelection().toString() +
'\n"""\n') +
'&page=' + page);


Here's the same bookmarklet formatted for inclusion in your browser's menubar:
javascript:var%20d=new%20Date();var%20padded=function(v)%20{%20var%20res%20=%20v.toString();while%20(res.length%20<%202)%20{res%20=%20'0'%20+%20res;}%20return%20res;};var%20page%20=%20[String(d.getFullYear()),%20padded(d.getMonth()%20+%201),%20padded(d.getDate())].join('-');location.href='voodoopad:description='+encodeURIComponent(location.href+'\n"""\n'+window.getSelection().toString()+'\n"""\n')+'&page='+page;

No comments: