Greasy Fork is available in English.
Turn only bright websites to dark.
当前为
// ==UserScript==
// @name Global Darkmode
// @description Turn only bright websites to dark.
// @name:ko 글로벌 다크모드
// @description:ko 밝은 색의 웹 사이트들만 어둡게 만듭니다.
// @namespace https://ndaesik.tistory.com/
// @version 2021.12.13.06:35
// @author ndaesik
// @icon https://www.google.com/s2/favicons?domain=earth.google.com
// @include *
// ==/UserScript==
const styleSheet = document.createElement("style")
styleSheet.type = "text/css"
styleSheet.innerText = `
html[w_root] {background:#FFF!important}
html[white]:not([w_root]) {background:unset!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}
`
document.head.appendChild(styleSheet)
function wd(target) {
const v = getComputedStyle(document.querySelector(target), null).getPropertyValue("background-color").match(/\d+/g);
const c = (parseInt(v[0])*0.299 + parseInt(v[1])*0.587 + parseInt(v[2])*0.114) > 186 || parseInt(v[3]) == 0;
return (c) ? true : false;
}
function n(n){document.documentElement.setAttribute(n, "");}
// set attribute
if ( self === top && wd("html") && wd("body") && window.parent.document.body.offsetHeight !== 0 ) { n("white"); n("w_root"); };
if ( self !== top && wd("html") && wd("body") ) { n("white"); };
if (window.parent.document.body.offsetHeight == 0) {
let max;
document.querySelectorAll('body > *').forEach(e=>{
if (max == null || e.scrollHeight > max.scrollHeight) max = e;
});
const v2 = getComputedStyle(max, null).getPropertyValue("background-color").match(/\d+/g);
const c2 = (parseInt(v2[0])*0.299 + parseInt(v2[1])*0.587 + parseInt(v2[2])*0.114) > 186 || parseInt(v2[3]) == 0;
if ( c2 == true ) {
if ( wd("html") ) { n("white"); n("w_root");
} else { n("white"); }
}
};