Geoff Garbers

Husband. Programmer. Tinkerer.

You want funky disco? I give you funky disco!

Apr 01, 2011

I came across a great bit of Javascript that turns a web page into a disco. I thought I’d package it as a bookmarklet, so you can try it out on any site you come across (it seems to work much better in Chrome than it does in Firefox).

Warning: If you are epileptic, it would not be a good idea to click this link!

Drag this bookmarklet to your bookmarks: Discofy!. Or, click the link and discofy this page.

Here’s the source code:

javascript:(function disco() { var elements = document.getElementsByTagName('*'); for (var i = elements.length - 1; i >= 0; i--) { var r = Math.floor(Math.random()*256); var g = Math.floor(Math.random()*256); var b = Math.floor(Math.random()*256); elements[i].style.color = '#'+r.toString(16)+g.toString(16)+b.toString(16); var r = Math.floor(Math.random()*256); var g = Math.floor(Math.random()*256); var b = Math.floor(Math.random()*256); elements[i].style.backgroundColor = '#'+r.toString(16)+g.toString(16)+b.toString(16); }; setTimeout(disco, 20); })();

Found via @timdorr