// ==UserScript== // @name Global Darkmode // @description Turn only bright websites to dark. // @name:ko 글로벌 다크모드 // @description:ko 밝은 색의 웹 사이트들만 어둡게 만듭니다. // @namespace https://ndaesik.tistory.com/ // @version 2021.12.13.23:22 // @author ndaesik // @icon https://www.google.com/s2/favicons?domain=earth.google.com // @include * // @downloadURL none // ==/UserScript== const gDM = document.createElement("style") gDM.title = `gDM` gDM.innerText = ` html {background:#FFF!important} html body {background:none!important} html * {text-shadow:0 0 .1px} html, html :is(i, img, image, embed, video, canvas, option, object, frame, :fullscreen:not(iframe), iframe:not(:fullscreen), body frameset), html body>* [style*="url("]:not([style*="cursor:"]):not([type="text"]) {filter:invert(1)hue-rotate(180deg)!important} html video:fullscreen, html body>* [style*="url("]:not([style*="cursor:"]) :not(#⁠){filter:unset!important} html:not(#⁠) :is(canvas, option, object, frame, body frameset) :is(i, img, image, embed, video), html:not(#⁠) video:fullscreen{filter:unset!important}` const gDMI = document.createElement("style") gDMI.title = `gDMI` gDMI.innerText = `html:not(#⁠) {background:unset!important}` function a(a) {document.head.appendChild(a)}; function m(m) { function n(n) { let v = getComputedStyle(document.querySelector(m), null).getPropertyValue("background-color").match(/\d+/g); return parseInt(v[n]); }; let c = (n(0)*0.299 + n(1)*0.587 + n(2)*0.114) > 186 || n(3) == 0; return (c) ? true : false; }; if((self === top && m("html") && m("body") && window.parent.document.body.offsetHeight !== 0) || (self !== top && m("html") && m("body"))) a(gDM); if(window.parent.document.body.offsetHeight == 0) { let container; document.querySelectorAll('body > *').forEach(e=>{ if ( e.scrollHeight > container.scrollHeight) container = e }); if(m(container)) { a(gDMI); if(!m("html")) a(gDMI); } };