Dive Into Greasemonkey

Teaching an old web new tricks

5.2. Case study: Bloglines Autoload

Automating page actions

Bloglines is a web-based aggregator for syndicated feeds. It has a 2-pane interface; the left-hand pane displays your subscriptions, and the right-hand pane displays the content from those subscriptions. It's a very nice interface; the only thing I dislike about it is that I always use it the same way: every time I visit Bloglines, I want to see everything I haven't seen before, that is, all the unread items.

In Bloglines, displaying all unread items is just one click away. Clicking on the root level of your subscriptions in the lefthand pane, and it displays the unread items in the righthand pane. But since I always want to do this, I wrote a user script to automate that one click.

Example: Make Bloglines display all unread items automatically

// ==UserScript==
// @name          Bloglines Autoloader
// @namespace     http://diveintogreasemonkey.org/download/
// @description   Auto-display all new items in Bloglines
// @include       http://bloglines.com/myblogs*
// @include       http://www.bloglines.com/myblogs*
// ==/UserScript==

if (doLoadAll) {
    doLoadAll();
}

This user script is quite simple. Bloglines defines a function, doLoadAll(), which is what would get executed if I manually clicked on the root level of my subscriptions list. Calling the function displays all unread items.

However, since Bloglines uses frames, the user script will end up getting executed in each frame (since they all match the pattern I've defined in the @include), so I first need to check whether the doLoadAll() function exists in this frame:

if (doLoadAll) {

Assumes the function exists, I simply call it. Since the user script runs in the same context as the page, I can call any scripts that the original page has defined.

    doLoadAll();
    }
← Case study: GMail Secure
Case study: Ain't It Readable →