深色模式

适合几乎所有网站

目前为 2022-01-27 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 深色模式
  3. // @namespace https://fcmsb250.github.io/
  4. // @version 0.1
  5. // @description 适合几乎所有网站
  6. // @author dsy
  7. // @match *://*/*
  8. // @grant GM_addStyle
  9. // @grant GM_getValue
  10. // @grant GM_registerMenuCommand
  11. // @grant GM_setValue
  12. // @run-at document-start
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. (() => {
  17. var 改变值 = (值, 默认值, 回调) => {
  18. if (GM_getValue(值, 默认值) == "1") {
  19. GM_setValue(值, "0");
  20. } else if (GM_getValue(值, 默认值) == "0") {
  21. GM_setValue(值, "1");
  22. } else {
  23. GM_setValue(值, 默认值);
  24. }
  25. if (回调) {
  26. 回调();
  27. }
  28. };
  29. var 初始化值 = (值, 默认值, 回调) => {
  30. if (GM_getValue(值, "天知道是啥") == "天知道是啥") {
  31. GM_setValue(值, 默认值);
  32. }
  33. if (回调) {
  34. 回调();
  35. }
  36. };
  37. 初始化值("对图片视频等再次反色", "1");
  38. 初始化值("去部分网站背景图片", "0");
  39.  
  40. GM_registerMenuCommand("对图片视频等再次反色", () => {
  41. 改变值("对图片视频等再次反色", "1", () => {
  42. alert("刷新后生效");
  43. });
  44. });
  45. GM_registerMenuCommand("去背景图片", () => {
  46. 改变值("去背景图片", "0", () => {
  47. alert("刷新后生效");
  48. });
  49. });
  50. })();
  51.  
  52. (() => {
  53. "use strict";
  54. var css1 = `
  55. ::selection {
  56. color: white !important;
  57. background-color: white !important;
  58. }
  59. ::-webkit-scrollbar {
  60. background-color: black !important;
  61. }
  62. ::-webkit-scrollbar-thumb {
  63. background: rgb(100, 100, 100) !important;
  64. }
  65. html {
  66. text-shadow: 0 0 0 !important;
  67. background-color: white !important;
  68. }
  69. `;
  70. var css2 = `
  71. img,
  72. video,
  73. svg,
  74. canvas {
  75. filter: invert(1) !important;
  76. }
  77. `;
  78. var 对图片视频等再次反色 = GM_getValue("对图片视频等再次反色") == "1";
  79.  
  80. if (对图片视频等再次反色) {
  81. GM_addStyle(css2);
  82. }
  83. GM_addStyle(css1);
  84.  
  85. if (self == top) {
  86. GM_addStyle("html{ filter: invert(100%) brightness(0.3) !important; }");
  87. }
  88.  
  89. addEventListener("load", () => {
  90. if (GM_getValue("去背景图片") == "1") {
  91. document.body.style.backgroundImage = "none";
  92. document.documentElement.style.backgroundImage = "none";
  93. }
  94.  
  95. document.querySelectorAll("*").forEach((element) => {
  96. if (
  97. getComputedStyle(element).backgroundImage.indexOf("url") >= 0 &&
  98. element != document.body &&
  99. element != document.documentElement &&
  100. 对图片视频等再次反色
  101. ) {
  102. element.style.filter = "invert(1)";
  103. }
  104. });
  105. });
  106. })();

QingJ © 2025

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