Created
January 5, 2015 13:47
-
-
Save glenjamin/8b69f41b2edbd384f5e2 to your computer and use it in GitHub Desktop.
self-censor current page
This file contains hidden or 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
function blacken() { | |
var div = document.createElement('div'); | |
var opacity = 0; | |
div.style.position = 'fixed'; | |
div.style.top = 0; | |
div.style.bottom = 0; | |
div.style.left = 0; | |
div.style.right = 0; | |
div.style.opacity = opacity; | |
div.style.background = 'black'; | |
document.body.appendChild(div); | |
var timer = setInterval(darken, 100); | |
function darken() { | |
opacity += 0.005; | |
div.style.opacity = opacity; | |
if (opacity >= 1) clearInterval(timer); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment