// ==UserScript== // @name Global Darkmode // @name:ko 글로벌 다크모드 // @name:jp グローバルダークモード // @name:zh-TW 全局暗模式 // @name:zh-CN 全局暗模式 // @description Turn only bright websites to dark. // @description:ko 밝은 색의 웹 사이트들만 어둡게 만듭니다. // @description:jp 明るいウェブサイトだけを暗くします。 // @description:zh-TW 它只會將明亮的網站變為黑暗。 // @description:zh-CN 它只会将明亮的网站变为黑暗。 // @namespace https://ndaesik.tistory.com/ // @version 2021.12.27.01:02 // @author ndaesik // @icon data:image/svg+xml,🪐 // @include * // @downloadURL none // ==/UserScript== let bodyH = window.parent.document.body.offsetHeight, elems = document.querySelectorAll("body > :not(script)"), apply = () => {document.head.appendChild(drkMo)}, drkMo = document.createElement("style"), check = (m,m2=0) => { let n = (n) => {return parseInt(getComputedStyle(document.querySelectorAll(m)[m2]).getPropertyValue("background-color").match(/\d+/g)[n])}; return (n(0)*0.299+n(1)*0.587+n(2)*0.114) > 186 || n(3) == 0 } drkMo.innerText = ` html {color-scheme:dark!important;color:#000} html * {color-scheme:light!important;text-shadow:0 0 .1px} html body {background:none!important} html, html :is(i, img, image, embed, video, canvas, option, object, :fullscreen:not(iframe), iframe:not(:fullscreen)), html body>* [style*="url("]:not([style*="cursor:"]):not([type="text"]) {filter:invert(1)hue-rotate(180deg)!important} html body>* [style*="url("]:not([style*="cursor:"]) :not(#⁠), html:not(#⁠) :is(canvas, option, object) :is(i, img, image, embed, video), html:not(#⁠) video:fullscreen{filter:unset!important}` if ((self == top && bodyH != 0 || self != top) && (check("html") && check("body"))) apply(); if (bodyH == 0) {for (let i= 0; i < elems.length ; i++) {if (elems[i].scrollHeight > window.innerHeight && check("body > :not(script)",i)) apply();}};