|
1 | 1 | // ==UserScript== |
2 | 2 | // @name 护眼模式 |
3 | | -// @version 1.1.2 |
| 3 | +// @version 1.1.3 |
4 | 4 | // @author X.I.U |
5 | 5 | // @description 简单有效的全网通用护眼模式、夜间模式、暗黑模式 |
6 | 6 | // @match *://*/* |
|
26 | 26 | ['menu_runDuringTheDay', '白天保持开启 (比晚上亮一点点)', '白天保持开启', true], |
27 | 27 | ['menu_autoRecognition', '排除自带暗黑模式的网页 (beta)', '排除自带暗黑模式的网页 (beta)', true], |
28 | 28 | ['menu_darkModeType', '点击切换模式', '点击切换模式', 1] |
29 | | - ], menu_ID = [], websiteList = ['rarbgprx.org','fitgirl-repacks.site','masquerade.site']; |
| 29 | + ], menu_ID = [], websiteList = ['rarbgprx.org','fitgirl-repacks.site','masquerade.site','www.gamersky.com']; |
30 | 30 | for (let i=0;i<menu_ALL.length;i++){ // 如果读取到的值为 null 就写入默认值 |
31 | 31 | if (GM_getValue(menu_ALL[i][0]) == null){GM_setValue(menu_ALL[i][0], menu_ALL[i][3])}; |
32 | 32 | } |
|
98 | 98 | let remove = false, style_Add = document.createElement('style'), |
99 | 99 | hours = new Date().getHours(), |
100 | 100 | style = ``, |
101 | | - style_00 = `html {background-color: #ffffff;}`, |
| 101 | + style_00 = `html, body {background-color: #ffffff;}`, |
102 | 102 | style_11 = `html {filter: brightness(80%) !important;}`, |
103 | 103 | style_11_firefox = `html {filter: brightness(80%) !important; background-image: url();}`, |
104 | 104 | style_12 = `html {filter: brightness(70%) !important;}`, |
|
108 | 108 | style_22 = `html {filter: brightness(70%) sepia(30%) !important;}`, |
109 | 109 | style_22_firefox = `html {filter: brightness(70%) sepia(30%) !important; background-image: url();}`, |
110 | 110 | style_31 = `html {filter: invert(80%) !important;} img, video {filter: invert(1) !important;}`, |
111 | | - style_31_firefox = `html {filter: invert(80%) !important;} img, video {filter: invert(1) !important; background-image: url();}`; |
| 111 | + style_31_firefox = `html {filter: invert(80%) !important; background-image: url();} img, video {filter: invert(1) !important;}`; |
112 | 112 |
|
113 | 113 | // Firefox 浏览器需要特殊对待 |
114 | 114 | if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { |
|
141 | 141 | break; |
142 | 142 | } |
143 | 143 | style_Add.id = 'XIU2DarkMode'; |
| 144 | + style_Add.type = 'text/css'; |
144 | 145 | //console.log(document,document.lastChild,document.querySelector('html')) |
145 | 146 | if (document.lastChild) { |
146 | 147 | document.lastChild.appendChild(style_Add).textContent = style; |
|
212 | 213 | } |
213 | 214 | } |
214 | 215 | }, 3000);*/ |
| 216 | + |
| 217 | + // 解决远景论坛会清理掉前面插入的 CSS 样式的问题 |
| 218 | + if (location.hostname === 'bbs.pcbeta.com') { |
| 219 | + let timer1 = setInterval(function(){ |
| 220 | + if (!document.getElementById('XIU2DarkMode')) { |
| 221 | + document.lastChild.appendChild(style_Add).textContent = style; |
| 222 | + clearInterval(timer1); |
| 223 | + } |
| 224 | + }, 10); |
| 225 | + } |
215 | 226 | } |
216 | 227 |
|
217 | 228 | // 获取背景颜色值 |
|
0 commit comments