Skip to content

Instantly share code, notes, and snippets.

@lwcorp
lwcorp / darkthemeswitcher-inline.js
Last active June 17, 2023 12:30 — forked from frontdevops/darkthemeswitcher-inline.js
Simple Dark Theme Bookmarklet for web pages, but without affecting iframes (like embedded YouTube) and images that use background-image= instead of <img
javascript:(d=>{var css=`:root{background-color:#fefefe;filter:invert(100%)}*{background-color:inherit}iframe,[style*="background-image:"]:not([style$=".svg)"]),img:not([src*=".svg"]),video{filter:%20invert(100%)}`,style,id="dark-theme-snippet",ee=d.getElementById(id);if(null!=ee)ee.parentNode.removeChild(ee);else%20{style%20=%20d.createElement('style');style.type="text/css";style.id=id;if(style.styleSheet)style.styleSheet.cssText=css;else%20style.appendChild(d.createTextNode(css));(d.head||d.querySelector('head')).appendChild(style)}})(document)