Skip to content

Instantly share code, notes, and snippets.

@simsketch
Created September 3, 2020 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simsketch/29cc4bda684b713805776b16292644fd to your computer and use it in GitHub Desktop.
Save simsketch/29cc4bda684b713805776b16292644fd to your computer and use it in GitHub Desktop.
Dark Mode in one line
let sheet = (function () {
// Create the <style> tag
var style = document.createElement('style');
// Add a media (and/or media query) here if you'd like!
// style.setAttribute("media", "screen")
// style.setAttribute("media", "only screen and (max-width : 1024px)")
// WebKit hack :(
style.appendChild(document.createTextNode(''));
// Add the <style> element to the page
document.head.appendChild(style);
return style.sheet;
})();
sheet.insertRule(':root{filter: invert(.85) saturate(0)}', 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment