Created
September 8, 2017 14:07
-
-
Save cferdinandi/28a8896007cd26d91c6b8a403f4180b3 to your computer and use it in GitHub Desktop.
A simple script for toggling night mode on/off on a website.
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
var toggleNightMode = function () { | |
var nightMode = document.querySelector('#night-mode-styles'); | |
if (nightMode) { | |
nightMode.parentNode.removeChild(nightMode); | |
return; | |
} | |
var ref = window.document.getElementsByTagName('script')[0]; | |
nightMode = document.createElement('style'); | |
nightMode.id = 'night-mode-styles'; | |
nightMode.innerHTML = 'body{filter:invert(1) hue-rotate(180deg);background:#000000;}iframe,img,video{filter:invert(1) hue-rotate(180deg);}img{opacity:0.7;}img:hover{opacity:1;}'; | |
ref.parentNode.insertBefore(nightMode, ref); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Never trust AI, or Brave
https://gomakethings.com/rage-against-the-ai-machine/
https://gomakethings.com/i-follow-you-for-tech-not-politics/