全局暗模式

它只会将明亮的网站变为黑暗。

目前为 2021-12-19 提交的版本。查看 最新版本

// ==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.19.13:04
// @author            ndaesik
// @icon              https://www.google.com/s2/favicons?domain=earth.google.com
// @include           *
// ==/UserScript==
const w = window,
      d = document,
      dqa = d.querySelectorAll,
      wpdbh = w.parent.document.body.offsetHeight,
      gdm = d.createElement("style")
if (w.location != w.parent.location) d.documentElement.setAttribute("iframed","");

gdm.innerText = `
html:not([iframed]) {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}`
function i() {d.head.appendChild(gdm)};

function m(m,m2=0) {
    function n(n) {return parseInt(getComputedStyle(d.querySelectorAll(m)[m2], null).getPropertyValue("background-color").match(/\d+/g)[n])};
    return (n(0)*0.299+n(1)*0.587+n(2)*0.114) > 186 || n(3) == 0 // return true when the background is bright.
};
if ((self == top && wpdbh != 0 || self != top) && (m("html") && m("body"))) i();
if (wpdbh == 0) {
    let bda = d.querySelectorAll("body > :not(script)");
    for (var a = 0, j = bda.length; a < j ; a++) {
        if (bda[a].scrollHeight > w.innerHeight) {
            if (m("body > :not(script)",a)) i();
        }
    }
};

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址