Global Darkmode

Turn in bright websites to dark.

目前為 2021-10-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name           Global Darkmode
// @description    Turn in bright websites to dark.

// @name:ko        글로벌 다크모드
// @description:ko 밝은 색의 웹 사이트들을 어둡게 만듭니다.

// @namespace      https://ndaesik.tistory.com/
// @version        2021.10.28.21:22
// @author         ndaesik
// @icon        data:image/webp;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAJSUExURUdwTICAgICAgICAgAAAAAAAAICAgICAgICAgAAAAICAgICAgICAgICAgICAgICAgICAgICAgAAAAICAgICAgH9/f39/f4KCgoCAgICAgICAgICAgICAgH9/f////4CAgICAgICAgH9/fyEhIYKCgoCAgICAgH5+foCAgFhYWGNjY4SEhBkZGYGBgYGBgYGBgYCAgHBwcBwcHHd3d4CAgICAgFFRUYCAgBwcHICAgD4+PgAAAICAgC4uLl5eXgAAAICAgICAgEVFRX19fWhoaHt7e3FxcYCAgEBAQG1tbTMzM4GBgYCAgBoaGnZ2doGBgYCAgH19faSkpGBgYGZmZoCAgHZ2dhUVFXd3d4CAgEdHR2lpaTY2NkJCQoGBgW9vb29vb4GBgYCAgICAgICAgGlpaWpqaoCAgJOTk4CAgCgoKIKCgoCAgBsbGwAAAF1dXUZGRsHBwXV1dYGBgX9/f2hoaGtrazk5OW1tbYGBgWNjY0BAQIGBgWpqampqamlpaXl5eYeHhx8fH2ZmZoCAgIaGhmpqaoaGhoKCgoCAgGVlZTw8PHh4eIyMjEpKSm9vb1paWiYmJqGhoXt7e1FRUYCAgIGBgR4eHkZGRm5ubnt7e1paWoGBgXt7e2BgYHl5eUdHR7CwsIeHh0xMTICAgIiIiGxsbGZmZnx8fICAgICAgEhISICAgGZmZmhoaImJiXp6eoCAgICAgDc3N1BQUEpKSoCAgIKCgoCAgICAgIGBgYSEhICAgIODg////4GBgZWVlYCAgFJSUlFRUQB5fYCAgF0w2js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V5xHqOtpxrRWKKmteNYU29tkPlOWygQoFb/odCH1CnzMgq1NVOjehR7khrNRrG2dmpTj1J2UxcTJUVOUw/jR5S2hHpMh50d1MF4C7YC1OA92FtYR+WSYTg4StXSs+DoJyr2Apw9HqdSf6Gc+wwqFEd5G6nOiTAEDISoSG4ehGwwqcShPgi6x6QCgT4I2xCidJmVcGGAssUOwpWNBqVaHoFLZ+KU6LMZcO1kN2WJHrDgxdEEpah5Bh5d30QJ2lvg3Q76FfwFvvzcSF9ug1+R3XPoWWMnJGgbbqYnW1ZAkqqvA3TLePQIZPqkOUoXotWTId0DIQpKDEGJyB1DCZaVvbgN6lR1ru+J09bUX6etqYJq4Z2LjieXt5rMkxn34sjnrzwFncK7br9736s33d//0LL9X2HMGI/+BysZfqgS/wmSAAAAAElFTkSuQmCC
// @include        *
// ==/UserScript==

// Turn light page to dark
var styles = `
html[w_root] {background:#FFF!important}
html[white] body {background:none!important}
html[white] * {text-shadow:0 0 .1px}
html[white],
html[white] :is(i, img, image, embed, video, canvas, option, object, frame, :fullscreen:not(iframe), iframe:not(:fullscreen), body frameset),
html[white] body>* [style*="url("]:not([style*="cursor:"]):not([type="text"]) {filter:invert(1)hue-rotate(180deg)!important}
html[white] video:fullscreen,
html[white] body>* [style*="url("]:not([style*="cursor:"]) :not(#⁠){filter:unset!important}

html[white]:not(#⁠) :is(canvas, option, object, frame, body frameset) :is(i, img, image, embed, video),
html[white]:not(#⁠) video:fullscreen{filter:unset!important}
`

const styleSheet = document.createElement("style")
styleSheet.type = "text/css"
styleSheet.innerText = styles
document.head.appendChild(styleSheet)

// Detect page is whether light or dark
const v = getComputedStyle(document.body, null).getPropertyValue("background-color");
const m = v.match(/\d+/g);
const r = parseInt(m[0]);
const g = parseInt(m[1]);
const b = parseInt(m[2]);
const checkWhite = (r + g + b) > 500 || v == 'rgba(0, 0, 0, 0)';
function n(n){document.documentElement.setAttribute(n, "");}

// set attribute
if ( self === top ) {
    if ( checkWhite && window.parent.document.body.offsetHeight !== 0 ) {
        n("white");
        n("w_root");
    } else {
        // dark root
    }
};

if ( self !== top ) {
    if ( window.parent.document.querySelector('html[w_root]') !== null && !( checkWhite )) {
        // is white rooted black children
    } else {
        n("white");
    }
};

QingJ © 2025

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