|
1 | 1 | // ==UserScript== |
2 | 2 | // @name 护眼模式 |
3 | | -// @version 1.1.1 |
| 3 | +// @version 1.1.2 |
4 | 4 | // @author X.I.U |
5 | 5 | // @description 简单有效的全网通用护眼模式、夜间模式、暗黑模式 |
6 | 6 | // @match *://*/* |
|
164 | 164 | let style_Add2 = document.createElement('style'); |
165 | 165 | style_Add2.id = 'XIU2DarkMode2'; |
166 | 166 | document.lastChild.appendChild(style_Add2).textContent = style_00; |
167 | | - } else if (window.getComputedStyle(document.body).backgroundColor === 'rgb(0, 0, 0)' || getColorValue(document.body) > 0 && getColorValue(document.body) < 898989 || getColorValue(document.lastChild) > 0 && getColorValue(document.lastChild) < 898989) { |
| 167 | + } else if (window.getComputedStyle(document.body).backgroundColor === 'rgb(0, 0, 0)' || getColorValue(document.body) > 0 && getColorValue(document.body) < 898989 || getColorValue(document.lastChild) > 0 && getColorValue(document.lastChild) < 898989 || window.getComputedStyle(document.body).backgroundColor === 'rgba(0, 0, 0, 0)' && window.getComputedStyle(document.lastChild).backgroundColor === 'rgb(0, 0, 0)') { |
168 | 168 | // 如果是黑色 (等于0,0,0) 或深色 (小于 89,89,89),就停用本脚本滤镜 |
169 | 169 | if (menu_value('menu_autoRecognition')) { // 排除自带暗黑模式的网页 (beta) |
170 | 170 | for (let i=0;i<websiteList.length;i++){ // 这些网站强制启用护眼模式滤镜 |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | }, 150); |
| 179 | + |
| 180 | + // 用来解决一些 CSS 加载缓慢的网站,可能会出现没有正确排除的问题,在没有找到更好的办法之前,先这样凑活着用 |
| 181 | + setTimeout(function(){ |
| 182 | + console.log('html:', window.getComputedStyle(document.lastChild).backgroundColor, 'body:', window.getComputedStyle(document.body).backgroundColor) |
| 183 | + if (window.getComputedStyle(document.body).backgroundColor === 'rgb(0, 0, 0)' || getColorValue(document.body) > 0 && getColorValue(document.body) < 898989 || getColorValue(document.lastChild) > 0 && getColorValue(document.lastChild) < 898989 || window.getComputedStyle(document.body).backgroundColor === 'rgba(0, 0, 0, 0)' && window.getComputedStyle(document.lastChild).backgroundColor === 'rgb(0, 0, 0)') { |
| 184 | + // 如果是黑色 (等于0,0,0) 或深色 (小于 89,89,89),就停用本脚本滤镜 |
| 185 | + if (menu_value('menu_autoRecognition')) { // 排除自带暗黑模式的网页 (beta) |
| 186 | + for (let i=0;i<websiteList.length;i++){ // 这些网站强制启用护眼模式滤镜 |
| 187 | + if (websiteList[i] === location.host) return |
| 188 | + } |
| 189 | + if (remove) return |
| 190 | + console.log('检测到当前网页自带暗黑模式,停用本脚本滤镜...') |
| 191 | + if (document.getElementById('XIU2DarkMode')) document.getElementById('XIU2DarkMode').remove(); |
| 192 | + if (document.getElementById('XIU2DarkMode2')) document.getElementById('XIU2DarkMode2').remove(); |
| 193 | + } |
| 194 | + } |
| 195 | + }, 1500); |
179 | 196 | } |
180 | 197 | }, 10); |
181 | 198 |
|
182 | | - // 在没有找到更好的办法之前,先这样凑活着用 |
183 | | - setTimeout(function(){ |
| 199 | + // 用来解决一些 CSS 加载缓慢的网站,可能会出现没有正确排除的问题,在没有找到更好的办法之前,先这样凑活着用 |
| 200 | + /*setTimeout(function(){ |
184 | 201 | console.log('html:', window.getComputedStyle(document.lastChild).backgroundColor, 'body:', window.getComputedStyle(document.body).backgroundColor) |
185 | 202 | if (window.getComputedStyle(document.body).backgroundColor === 'rgb(0, 0, 0)' || getColorValue(document.body) > 0 && getColorValue(document.body) < 898989 || getColorValue(document.lastChild) > 0 && getColorValue(document.lastChild) < 898989) { |
186 | 203 | // 如果是黑色 (等于0,0,0) 或深色 (小于 89,89,89),就停用本脚本滤镜 |
|
194 | 211 | if (document.getElementById('XIU2DarkMode2')) document.getElementById('XIU2DarkMode2').remove(); |
195 | 212 | } |
196 | 213 | } |
197 | | - }, 3000); |
| 214 | + }, 3000);*/ |
198 | 215 | } |
199 | 216 |
|
200 | 217 | // 获取背景颜色值 |
|
0 commit comments