Last active
August 29, 2015 14:20
-
-
Save johnwquarles/357a51887dd72464ddbf to your computer and use it in GitHub Desktop.
Whack-a-link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this will look better if you change the page's CSS to: | |
// .hide { | |
// visibility: hidden; } | |
function randomSeconds() { | |
return 10000 * Math.random(); | |
} | |
function setRespawns() { | |
var hiddenlinks = [].slice.call(document.querySelectorAll(".hide")); | |
hiddenlinks.forEach(function(link) { | |
setTimeout(function() { | |
link.classList.remove("hide"); | |
}, randomSeconds()); | |
}); | |
} | |
var links = [].slice.call(document.querySelectorAll("a")); | |
links.forEach(function(link) { | |
link.onclick = function(event) { | |
link.classList.add("hide"); | |
setRespawns(); | |
event.preventDefault(); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Playing around in the console. Put all this code in and when you click any link, it'll disappear and then reappear a few seconds later.