Bookmarklets

What's a bookmarklet?

A bookmarklet is a tiny JavaScript program that is stored in a bookmark in your web browser. They look exactly like regular bookmarks except that instead of taking you to a website, they execute some code on the currently viewed page. The power and convenience of bookmarklets are hard to explain without actually trying them out.

So why are they so cool?

Well, here's a few reasons:

  • No additional software needs to be installed (only JavaScript need to be enabled in your browser)
  • They provide virtually limitless control over what you do to a webpage
  • They're entirely customizable. You can do anything from stripping out Flash or images, extracting links or images, search page content, changing page colours, resizing the window - anything you can think of.
  • They're generally very fast to execute

What kind of limitations do they have?

Well, first the obvious: they don't actually change the webpage. Clicking refresh will revert the page back to the original state.

Secondly, there's size. Since bookmarks were designed to store URLs, they can only be as large as whatever your browser permits for a URL. With IE on PC, I believe it's around 2,000 characters. With Firefox and Mozilla, around 3 or 4,000. With IE on Mac, I've heard 507. Safari? 58. (Kidding).

Thirdly, they're often browser dependent. Being a very pro-Firefox sort of person (and because I really write these for my own personal use) I only make mine work for Firefox.

The dark side

On a more sinister note, bookmarklets provide hackers with a simple, convenient means to hack your site. Simple hacking techniques like inserting hidden form fields, enabling disabled fields, showing hidden fields, changing existing form values and many more, are made extremely easy with bookmarklets.

Speaking from personal experience, seeing how simple it is to hack a website teaches you to never trust form submission content.

See bookmarklets.com for a whole range of useful bookmarklets.


And a couple of my own...

Here's a couple of my own bookmarklets. Generally, I've found that most tasks I needed a bookmarklet for had already been written. But these two were special.