Last active
April 12, 2016 19:39
-
-
Save proimage/89f7e1be3431dfd4d4ba538c5b917cad to your computer and use it in GitHub Desktop.
This bookmarklet toggles a dark overlay (75% black) over any page you're viewing, handy for toning down those blindingly white pages in the middle of the night. To use, copy the entire contents of this Gist, create a new bookmark in your browser (the bookmarks bar is a good, handy location to put it), and paste the Gist as the URL of the bookmark.
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
javascript:(function(){overlay=document.getElementsByClassName('overlay--darken');if(overlay.length>0){overlay[0].parentNode.removeChild(overlay[0]);}else{_my_overlay=document.createElement('aside');_my_overlay.className='overlay--darken';_my_overlay.style='position:fixed;top:0;bottom:0;width:100%;pointer-events:none;background-color:rgba(0,0,0,0.75);z-index:9999;';document.getElementsByTagName('body')[0].appendChild(_my_overlay);}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BTW, this uses the CSS "pointer-events" property to allow the site "below" the overlay to be interacted with normally. Browser support is as seen here: http://beta.caniuse.com/#search=pointer-events - basically, IE 11+, and everything else (besides Opera Mini).