Random Dilbert bookmarklet

I’m addicted to the webcomic Dilbert by Scott Adams. He publishes one comic strip a day. With its archive ranging more than twenty years back, a random function to discover new old comics would be quite handy. That is what the following code snippet does: Create a random date between January 1st 1990April 16 1989 and today and navigate to that day’s comic address:

[code lang=”javascript”]javascript:function pad(n){return n<10 ? ‘0’+n : n} var now = Date.now(); var offset = (new Date(1989, 04, 16)).valueOf(); var rdate = new Date(offset + Math.round(Math.random() * (now-offset))); location.href = ‘http://dilbert.com/strips/comic/’ + rdate.getFullYear() + ‘-‘ + pad(rdate.getMonth()+1) + ‘-‘ + pad(rdate.getDate()) + ‘/’;[/code]

Just copy the text and add it as the URL to a new bookmark called “Random Dilbert”. Whenever you click on it, it takes you to a different comic.


Posted

in

by

Tags:

Comments

7 responses to “Random Dilbert bookmarklet”

  1. Leo

    Wow, super!
    Die nächste Kaffeepause kann kommen 🙂

  2. n1

    Klasse Sache!

    Dilbert fetzt! 🙂

  3. n1

    while(true)
    {
    Console.Write(“Einen guck ich noch, dann arbeite ich weiter”);
    Comic = ClickForNewRandomComic();
    }

  4. Works marvellously! Thank you! I find it weird that the main website doesn’t have a “random” button but this covers that nicely.

  5. Otto

    Ah great excaly what i needed…

  6. David

    Hi

    The first Dilbert comic is dated 1989-04-16, you should update your bookmarklet to start at this date.

    Regards