Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.