Last active
January 1, 2025 19:26
-
-
Save frontdevops/8aea1e0252dd826488dad63319e3ec88 to your computer and use it in GitHub Desktop.
Simple Dark Theme Bookmarklet for web pages
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:(d=>{var css=`:root{background-color:#fefefe;filter:invert(100%)}*{background-color:inherit}img:not([src*=".svg"]),video{filter: invert(100%)}`,style,id="dark-theme-snippet",ee=d.getElementById(id);if(null!=ee)ee.parentNode.removeChild(ee);else {style = d.createElement('style');style.type="text/css";style.id=id;if(style.styleSheet)style.styleSheet.cssText=css;else style.appendChild(d.createTextNode(css));(d.head||d.querySelector('head')).appendChild(style)}})(document) |
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: | |
(d=>{ | |
var css = ` | |
:root{ | |
background-color: #fefefe; | |
filter: invert(100%) | |
} | |
* { | |
background-color: inherit | |
} | |
img:not([src*=".svg"]), video{ | |
filter: invert(100%) | |
} | |
`, | |
style, | |
id="dark-theme-snippet", | |
ee = d.getElementById(id); | |
if (null != ee) ee.parentNode.removeChild(ee); | |
else { | |
style = d.createElement('style'); | |
style.type = "text/css"; | |
style.id = id; | |
if (style.styleSheet) style.styleSheet.cssText = css; | |
else style.appendChild(d.createTextNode(css)); | |
(d.head||d.querySelector('head')).appendChild(style); | |
} | |
})(document) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've forked it into a version that does not ruin
iframe
s (like embedded YouTube) and images that usebackground-image=
instead of<img
.