全局暗模式

它只會將明亮的網站變為黑暗。

目前為 2021-12-19 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Global Darkmode
  3. // @name:ko 글로벌 다크모드
  4. // @name:jp グローバルダークモード
  5. // @name:zh-TW 全局暗模式
  6. // @name:zh-CN 全局暗模式
  7.  
  8. // @description Turn only bright websites to dark.
  9. // @description:ko 밝은 색의 웹 사이트들만 어둡게 만듭니다.
  10. // @description:jp 明るいウェブサイトだけを暗くします。
  11. // @description:zh-TW 它只會將明亮的網站變為黑暗。
  12. // @description:zh-CN 它只会将明亮的网站变为黑暗。
  13.  
  14. // @namespace https://ndaesik.tistory.com/
  15. // @version 2021.12.19.13:09
  16. // @author ndaesik
  17. // @icon https://www.google.com/s2/favicons?domain=earth.google.com
  18. // @include *
  19. // ==/UserScript==
  20. const w = window,
  21. d = document,
  22. dqa = d.querySelectorAll,
  23. wpdbh = w.parent.document.body.offsetHeight,
  24. gdm = d.createElement("style")
  25. gdm.innerText = `
  26. html:not([iframed]) {background:#FFF!important}
  27. html body {background:none!important}
  28. html * {text-shadow:0 0 .1px}
  29. html,
  30. html :is(i, img, image, embed, video, canvas, option, object, frame, :fullscreen:not(iframe), iframe:not(:fullscreen), body frameset),
  31. html body>* [style*="url("]:not([style*="cursor:"]):not([type="text"]) {filter:invert(1)hue-rotate(180deg)!important}
  32. html video:fullscreen,
  33. html body>* [style*="url("]:not([style*="cursor:"]) :not(#⁠){filter:unset!important}
  34. html:not(#⁠) :is(canvas, option, object, frame, body frameset) :is(i, img, image, embed, video),
  35. html:not(#⁠) video:fullscreen{filter:unset!important}`
  36. function i() {d.head.appendChild(gdm)};
  37. if (w.location != w.parent.location) d.documentElement.setAttribute("iframed","");
  38.  
  39. function m(m,m2=0) {
  40. function n(n) {return parseInt(getComputedStyle(d.querySelectorAll(m)[m2], null).getPropertyValue("background-color").match(/\d+/g)[n])};
  41. return (n(0)*0.299+n(1)*0.587+n(2)*0.114) > 186 || n(3) == 0 // return true when the background is bright.
  42. };
  43. if ((self == top && wpdbh != 0 || self != top) && (m("html") && m("body"))) i();
  44. if (wpdbh == 0) {
  45. let bda = d.querySelectorAll("body > :not(script)");
  46. for (var a = 0, j = bda.length; a < j ; a++) {
  47. if (bda[a].scrollHeight > w.innerHeight) {
  48. if (m("body > :not(script)",a)) i();
  49. }
  50. }
  51. };

QingJ © 2025

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