mirror of
https://github.com/XIU2/UserScript.git
synced 2026-07-24 11:03:23 +00:00
优化 [排除自带暗黑模式的网页 (beta)] 功能
This commit is contained in:
+22
-5
@@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name 护眼模式
|
||||
// @version 1.1.1
|
||||
// @version 1.1.2
|
||||
// @author X.I.U
|
||||
// @description 简单有效的全网通用护眼模式、夜间模式、暗黑模式
|
||||
// @match *://*/*
|
||||
@@ -164,7 +164,7 @@
|
||||
let style_Add2 = document.createElement('style');
|
||||
style_Add2.id = 'XIU2DarkMode2';
|
||||
document.lastChild.appendChild(style_Add2).textContent = style_00;
|
||||
} 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) {
|
||||
} 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)') {
|
||||
// 如果是黑色 (等于0,0,0) 或深色 (小于 89,89,89),就停用本脚本滤镜
|
||||
if (menu_value('menu_autoRecognition')) { // 排除自带暗黑模式的网页 (beta)
|
||||
for (let i=0;i<websiteList.length;i++){ // 这些网站强制启用护眼模式滤镜
|
||||
@@ -176,11 +176,28 @@
|
||||
}
|
||||
}
|
||||
}, 150);
|
||||
|
||||
// 用来解决一些 CSS 加载缓慢的网站,可能会出现没有正确排除的问题,在没有找到更好的办法之前,先这样凑活着用
|
||||
setTimeout(function(){
|
||||
console.log('html:', window.getComputedStyle(document.lastChild).backgroundColor, 'body:', window.getComputedStyle(document.body).backgroundColor)
|
||||
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)') {
|
||||
// 如果是黑色 (等于0,0,0) 或深色 (小于 89,89,89),就停用本脚本滤镜
|
||||
if (menu_value('menu_autoRecognition')) { // 排除自带暗黑模式的网页 (beta)
|
||||
for (let i=0;i<websiteList.length;i++){ // 这些网站强制启用护眼模式滤镜
|
||||
if (websiteList[i] === location.host) return
|
||||
}
|
||||
if (remove) return
|
||||
console.log('检测到当前网页自带暗黑模式,停用本脚本滤镜...')
|
||||
if (document.getElementById('XIU2DarkMode')) document.getElementById('XIU2DarkMode').remove();
|
||||
if (document.getElementById('XIU2DarkMode2')) document.getElementById('XIU2DarkMode2').remove();
|
||||
}
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
}, 10);
|
||||
|
||||
// 在没有找到更好的办法之前,先这样凑活着用
|
||||
setTimeout(function(){
|
||||
// 用来解决一些 CSS 加载缓慢的网站,可能会出现没有正确排除的问题,在没有找到更好的办法之前,先这样凑活着用
|
||||
/*setTimeout(function(){
|
||||
console.log('html:', window.getComputedStyle(document.lastChild).backgroundColor, 'body:', window.getComputedStyle(document.body).backgroundColor)
|
||||
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) {
|
||||
// 如果是黑色 (等于0,0,0) 或深色 (小于 89,89,89),就停用本脚本滤镜
|
||||
@@ -194,7 +211,7 @@
|
||||
if (document.getElementById('XIU2DarkMode2')) document.getElementById('XIU2DarkMode2').remove();
|
||||
}
|
||||
}
|
||||
}, 3000);
|
||||
}, 3000);*/
|
||||
}
|
||||
|
||||
// 获取背景颜色值
|
||||
|
||||
Reference in New Issue
Block a user