Skip to content

Instantly share code, notes, and snippets.

@heiswayi
Created October 17, 2020 20:16
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 heiswayi/9efcc456b65fd6242378c824d6e3dd77 to your computer and use it in GitHub Desktop.
Save heiswayi/9efcc456b65fd6242378c824d6e3dd77 to your computer and use it in GitHub Desktop.
Enforce dark mode
function addCss(rule) {
let css = document.createElement('style');
css.type = 'text/css';
if (css.styleSheet) css.styleSheet.cssText = rule;
else css.appendChild(document.createTextNode(rule));
document.getElementsByTagName("head")[0].appendChild(css);
}
var rule = ':root{background-color:#fff;filter:invert(100%)}*{background-color:inherit}img:not([src*=".svg"]),video{filter:invert(100%)}';
addCss(rule);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment