Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Created January 5, 2015 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glenjamin/8b69f41b2edbd384f5e2 to your computer and use it in GitHub Desktop.
Save glenjamin/8b69f41b2edbd384f5e2 to your computer and use it in GitHub Desktop.
self-censor current page
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