Bookmarklets

Bookmarklet is just like anyother bookmarks on your browser, instead of a URL it has small piece of javascript code. This piece of code can do lot of magic. It can access any DOM/objects a javascript within the HTML page can access.

One of the most of popular bookmarklet is Blog This ! If you frequently post other blogs or news articles on your blog, this a must have. To install it, drag this hyper link on to your bookmark tool bar. Now you have just installed a bookmarklet.

If you read the above bookmarklet, its a piece of javascript code.

 javascript: popw = '';
Q = '';
x = document;
y = window;
if (x.selection) {
    Q = x.selection.createRange().text;
} else if (y.getSelection) {
    Q = y.getSelection();
} else if (x.getSelection) {
    Q = x.getSelection();
}
popw = y.open('
http://www.blogger.com/blog_this.pyra?t=' + escape(Q) + '&u=' + escape(location.href) + '&n=' + escape(document.title), 'bloggerForm', 'scrollbars=no,width=475,height=300,top=175,left=75,status=yes,resizable=yes');
if (!document.all) T = setTimeout('popw.focus()', 50);
void(0);

 

NOTE: This bookmarklet is only for blogger.com

 

This code trys to extract the user selected text and opens a new window this text in it, along with title and hyper link information. And this new window will help you submit this content to your blog.

Next time you are reading a news article, you find it interesting and you would like to blog it. Just select the text you would like to be blogged and click on the bookmarklet, now edit the content how you want just click on submit.

Similarly you have Gmail This bookrmaklet to send any content as email using Gmail.

Bookmarklet is another reason why I love to use del.icio.us. When I work in lab, I don’t have my own system to work with, however I get a workstation in there. As I keep working, if I want to bookmark something, I just drag these bookmarlet on to the browser and I can start bookmarking to del.icio.us very easily.

A word of caution: With popularity of Ajax and most of the browser implementing it, its not very difficult for a bad programmer to steal your private information. So be careful where you download them from. If you know javascript read it once, you will know what it is doing. You can use this javascript beautifier to pretty-print the bookmarklet.

Have you ever encountered a site which says some features are free but force you to subscribe after few visits? I have encountered few websites like that. These sites basically keep  track of your visits via a cookie on your browser. Would it not be easy if you could just clear cookie and start using site, like the first time. You can do it by clearing cookies from your webbrowser. Firefox lets you clear cookies based on domain, but in IE you may have either manually delete or remove all of them. This take lot of steps and you need patience to do it. The easy way of doing it use this bookrmarklet called <2;++sl)for(p=”/”+location.pathname;p;p=p.substring(0,p.lastIndexOf(‘/’)))for(i%20in%20C)if(c=C[i]){document.cookie=c+”;%20domain=”+d.slice(sl)+”;%20path=”+p.slice(1)+”/”+”;%20expires=”+new%20Date((new%20Date).getTime()-1e11).toGMTString()}})()” target=”_blank”>zap cookies, it will just remove all the cookies for the current webpage (removes them based on the domain name). Here is code

 

javascript: (function() {
    C = document.cookie.split(“; “);
    for (d = “.” + location.host; d; d = (“” + d).substr(1).match(/\..*$/)) for (sl = 0; sl < 2; ++sl) for (p = “/” + location.pathname; p; p = p.substring(0, p.lastIndexOf(‘/’))) for (i in C) if (c = C[i]) {
        document.cookie = c + “; domain=” + d.slice(sl) + “; path=” + p.slice(1) + “/” + “; expires=” + new Date((new Date).getTime() – 1e11).toGMTString()
    }
})()

 

You also have View Cookies, View Scripts etc, these are very useful for developers.

 

As in some cases DOM/objects changes from browser to browser, not all bookmarklets work in all browsers. All the code/bookmarklets used here work with Firefox 2 and 3, get the one which is appropriate for your browser.

 

References

http://del.icio.us/help/buttons

http://help.blogger.com/bin/answer.py?hl=en&answer=41469

http://email.about.com/library/misc/blgmail_this_bookmarklet.htm

https://www.squarefree.com/bookmarklets/

Leave a Reply

You must be logged in to post a comment.