Global Darkmode

Turn only bright websites to dark.

当前为 2021-12-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Global Darkmode
  3. // @description Turn only bright websites to dark.
  4.  
  5. // @name:ko 글로벌 다크모드
  6. // @description:ko 밝은 색의 웹 사이트들만 어둡게 만듭니다.
  7.  
  8. // @namespace https://ndaesik.tistory.com/
  9. // @version 2021.12.13.23:22
  10. // @author ndaesik
  11. // @icon https://www.google.com/s2/favicons?domain=earth.google.com
  12. // @include *
  13. // ==/UserScript==
  14.  
  15. const gDM = document.createElement("style")
  16. gDM.title = `gDM`
  17. gDM.innerText = `
  18. html {background:#FFF!important}
  19. html body {background:none!important}
  20. html * {text-shadow:0 0 .1px}
  21. html,
  22. html :is(i, img, image, embed, video, canvas, option, object, frame, :fullscreen:not(iframe), iframe:not(:fullscreen), body frameset),
  23. html body>* [style*="url("]:not([style*="cursor:"]):not([type="text"]) {filter:invert(1)hue-rotate(180deg)!important}
  24. html video:fullscreen,
  25. html body>* [style*="url("]:not([style*="cursor:"]) :not(#⁠){filter:unset!important}
  26. html:not(#⁠) :is(canvas, option, object, frame, body frameset) :is(i, img, image, embed, video),
  27. html:not(#⁠) video:fullscreen{filter:unset!important}`
  28. const gDMI = document.createElement("style")
  29. gDMI.title = `gDMI`
  30. gDMI.innerText = `html:not(#⁠) {background:unset!important}`
  31.  
  32. function a(a) {document.head.appendChild(a)};
  33. function m(m) {
  34. function n(n) {
  35. let v = getComputedStyle(document.querySelector(m), null).getPropertyValue("background-color").match(/\d+/g);
  36. return parseInt(v[n]);
  37. };
  38. let c = (n(0)*0.299 + n(1)*0.587 + n(2)*0.114) > 186 || n(3) == 0;
  39. return (c) ? true : false;
  40. };
  41.  
  42. if((self === top && m("html") && m("body") && window.parent.document.body.offsetHeight !== 0) || (self !== top && m("html") && m("body"))) a(gDM);
  43. if(window.parent.document.body.offsetHeight == 0) {
  44. let container;
  45. document.querySelectorAll('body > *').forEach(e=>{ if ( e.scrollHeight > container.scrollHeight) container = e });
  46. if(m(container)) {
  47. a(gDMI);
  48. if(!m("html")) a(gDMI);
  49. }
  50. };

QingJ © 2025

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