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:

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()) + '/';

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.

7 thoughts on “Random Dilbert bookmarklet”

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

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

  3. Hi

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

    Regards

Comments are closed.