Skip to content

Instantly share code, notes, and snippets.

@switchtrue
Created December 2, 2013 03:24
Show Gist options
  • Save switchtrue/7744515 to your computer and use it in GitHub Desktop.
Save switchtrue/7744515 to your computer and use it in GitHub Desktop.
JavaScript to randomly make part of the screen comic sans and different colours. Purely used to annoy people that hate comic sans.
document.onclick = function () {
// get random table cells
var tdList = document.getElementsByTagName("td");
var i = 0;
while ( i != tdList.length )
{
if ( Math.floor(Math.random() * 20) == 0 )
{
// PRETTIFY!
tdList[i].style.color = '#ff00ff';
tdList[i].style.fontFamily = "Comic Sans MS";
if ( tdList[i].innerHTML.indexOf(">") == -1 )
{
var newTag = '<marquee>' + tdList[i].innerText + '</marquee>';
tdList[i].innerHTML = newTag;
}
}
i++;
}
var aList = document.getElementsByTagName("a");
i = 0;
while ( i != aList.length )
{
if ( Math.floor(Math.random() * 5) == 0 )
{
// make "dynamic"
if ( aList[i].innerHTML.indexOf(">") == -1 )
{
var newTag = '<marquee>' + aList[i].innerText + '</marquee>';
aList[i].innerHTML = newTag;
}
}
i++;
}
var buttonList = document.getElementsByTagName("input");
i = 0;
while ( i != buttonList.length )
{
if ( Math.floor(Math.random() * 2) == 0 )
{
// make "clearer"
buttonList[i].style.padding = Math.ceil(Math.random()*50) + 'px' + ' ' + Math.ceil(Math.random()*50) + 'px';
}
i++;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment