Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Unvale — force light mode (unofficial)
- // @namespace https://unvale.io
- // @version 1.0.0
- // @description Strips .dark from <html> so light :root / non-dark: styles win. Unofficial; may flicker.
- // @author you
- // @match https://unvale.io/*
- // @match https://www.unvale.io/*
- // @match https://*.unvale.io/*
- // @grant none
- // @run-at document-start
- // ==/UserScript==
- (function () {
- 'use strict';
- /** Remove next-themes dark class so Tailwind dark: and .dark tokens don’t apply */
- function stripDarkClass() {
- const el = document.documentElement;
- if (!el) return;
- if (el.classList.contains('dark')) {
- el.classList.remove('dark');
- }
- }
- // As early as possible
- stripDarkClass();
- function observe() {
- const el = document.documentElement;
- if (!el) return;
- stripDarkClass();
- const mo = new MutationObserver(() => {
- stripDarkClass();
- });
- mo.observe(el, {
- attributes: true,
- attributeFilter: ['class'],
- });
- }
- if (document.documentElement) {
- observe();
- } else {
- new MutationObserver(function (_, o) {
- if (document.documentElement) {
- o.disconnect();
- observe();
- }
- }).observe(document, { childList: true, subtree: true });
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment