// ==UserScript== // @name Global NightMode // @description Turn in bright websites to dark. // @name:ko 글로벌 나이트모드 // @description:ko 밝은 색의 웹 사이트들을 어둡게 만듭니다. // @namespace https://ndaesik.tistory.com/ // @version 2021.10.25.11:54 // @author ndaesik // @icon . // @include /^(?!.*youtube.com).*/ // @downloadURL none // ==/UserScript== // Turn light page to dark var styles = ` html:not([gd_pagecheck="dark"]) {background:white!important} html:not([gd_pagecheck="dark"]) body {background-image:unset!important} html:not([gd_pagecheck="dark"]) * {text-shadow:0 0 .1px} html:not([gd_pagecheck="dark"]), html:not([gd_pagecheck="dark"]):after, html:not([gd_pagecheck="dark"]) :is(img, embed, video, canvas, option, object, frame, :fullscreen:not(iframe), iframe:not(:fullscreen), body frameset) {filter:invert(1)hue-rotate(180deg)!important} html:not([gd_pagecheck="dark"]) video:fullscreen{filter:unset!important} ` var styleSheet = document.createElement("style") styleSheet.type = "text/css" styleSheet.innerText = styles document.head.appendChild(styleSheet) // Detect page is whether light or dark var v = getComputedStyle(document.querySelector("body"), null).getPropertyValue("background-color"); var m = v.match(/\d+/g); var r = parseInt(m[0]); var g = parseInt(m[1]); var b = parseInt(m[2]); if ((r + g + b) > 500 || v == 'rgba(0, 0, 0, 0)') { document.querySelector('html').setAttribute("gd_pagecheck", "light");} else{document.querySelector('html').setAttribute("gd_pagecheck", "dark");}