ponyoping

force light mode (unofficial)

Mar 27th, 2026
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Unvale — force light mode (unofficial)
  3. // @namespace https://unvale.io
  4. // @version 1.0.0
  5. // @description Strips .dark from <html> so light :root / non-dark: styles win. Unofficial; may flicker.
  6. // @author you
  7. // @match https://unvale.io/*
  8. // @match https://www.unvale.io/*
  9. // @match https://*.unvale.io/*
  10. // @grant none
  11. // @run-at document-start
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16. /** Remove next-themes dark class so Tailwind dark: and .dark tokens don’t apply */
  17. function stripDarkClass() {
  18. const el = document.documentElement;
  19. if (!el) return;
  20. if (el.classList.contains('dark')) {
  21. el.classList.remove('dark');
  22. }
  23. }
  24.  
  25. // As early as possible
  26. stripDarkClass();
  27. function observe() {
  28. const el = document.documentElement;
  29. if (!el) return;
  30. stripDarkClass();
  31. const mo = new MutationObserver(() => {
  32. stripDarkClass();
  33. });
  34.  
  35. mo.observe(el, {
  36. attributes: true,
  37. attributeFilter: ['class'],
  38. });
  39. }
  40. if (document.documentElement) {
  41. observe();
  42. } else {
  43. new MutationObserver(function (_, o) {
  44. if (document.documentElement) {
  45. o.disconnect();
  46. observe();
  47. }
  48. }).observe(document, { childList: true, subtree: true });
  49. }
  50. })();
Advertisement
Add Comment
Please, Sign In to add comment