Last active
October 15, 2018 16:30
-
-
Save JayPanoz/e9aac931795a152b0f2eb8494c6ead60 to your computer and use it in GitHub Desktop.
Poor man’s night mode
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
javascript:(function()%7Bvar%20nightEnabled%20%3D%20document.head.querySelector(%22%23my-night-style%22)%3Bif%20(nightEnabled)%20%7Bdocument.head.removeChild(nightEnabled)%3B%7D%20else%20%7Bvar%20nightStyle%20%3D%20document.createElement(%22style%22)%3BnightStyle.id%20%3D%20%22my-night-style%22%3BnightStyle.textContent%20%3D%20%22html%20%7Bfilter%3A%20invert(100%25)%20hue-rotate(180deg)%3B%7D%20img%2C%20svg%20%7Bfilter%3A%20invert(100%25)%20hue-rotate(180deg)%20!important%3B%7D%20video%20%7Bfilter%3A%20invert(100%25)%20hue-rotate(180deg)%20!important%3B%7D%22%3Bdocument.head.appendChild(nightStyle)%3B%7D%7D)() | |
Converted using Mr Coles’ Bookmarklet Creator: https://mrcoles.com/bookmarklet/ |
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
/* Alternatively, as a stylesheet you can automatically load in the browser (e.g. advanced prefs in Safari) */ | |
html { | |
filter: invert(100%) hue-rotate(180deg); | |
} | |
img, svg { | |
filter: invert(100%) hue-rotate(180deg) !important; | |
} | |
video { | |
filter: invert(100%) hue-rotate(180deg) !important; | |
} |
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
var nightEnabled = document.head.querySelector("#my-night-style"); | |
if (nightEnabled) { | |
document.head.removeChild(nightEnabled); | |
} else { | |
var nightStyle = document.createElement("style"); | |
nightStyle.id = "my-night-style"; | |
nightStyle.textContent = "html {filter: invert(100%) hue-rotate(180deg);} img, svg {filter: invert(100%) hue-rotate(180deg) !important;} video {filter: invert(100%) hue-rotate(180deg) !important;}"; | |
document.head.appendChild(nightStyle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment