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.
Comments
7 responses to “Random Dilbert bookmarklet”
Wow, super!
Die nächste Kaffeepause kann kommen 🙂
Klasse Sache!
Dilbert fetzt! 🙂
while(true)
{
Console.Write(“Einen guck ich noch, dann arbeite ich weiter”);
Comic = ClickForNewRandomComic();
}
Works marvellously! Thank you! I find it weird that the main website doesn’t have a “random” button but this covers that nicely.
Ah great excaly what i needed…
Hi
The first Dilbert comic is dated 1989-04-16, you should update your bookmarklet to start at this date.
Regards
Done!