优化 [智能排除自带暗黑模式的网页 (beta)] 自动排除含有 dark 标识的 html body 元素

This commit is contained in:
xiu2
2022-12-18 18:31:07 +08:00
parent 67f948eeb5
commit f08050ba34
+5 -5
View File
@@ -3,7 +3,7 @@
// @name:zh-CN 护眼模式
// @name:zh-TW 護眼模式
// @name:en Dark Mode
// @version 1.5.1
// @version 1.5.2
// @author X.I.U
// @description 简单有效的全网通用护眼模式(夜间模式、暗黑模式、深色模式)
// @description:zh-CN 简单有效的全网通用护眼模式(夜间模式、暗黑模式、深色模式)
@@ -439,8 +439,8 @@
style_Add2.id = 'XIU2DarkMode2';
document.lastElementChild.appendChild(style_Add2).textContent = style_00;
} else if ((document.querySelector('head>meta[name="color-scheme"],head>link[href^="resource:"]') && window.matchMedia('(prefers-color-scheme: dark)').matches) || window.getComputedStyle(document.body).backgroundColor === 'rgb(0, 0, 0)' || getColorValue(document.body) > 0 && getColorValue(document.body) < 898989 || getColorValue(document.lastElementChild) > 0 && getColorValue(document.lastElementChild) < 898989 || window.getComputedStyle(document.body).backgroundColor === 'rgba(0, 0, 0, 0)' && window.getComputedStyle(document.lastElementChild).backgroundColor === 'rgb(0, 0, 0)') {
// 如果是在资源页 且 浏览器为暗黑模式,或底色为黑色 (等于0,0,0) 或深色 (小于 89,89,89),就停用本脚本滤镜
} else if ((document.querySelector('head>meta[name="color-scheme"],head>link[href^="resource:"]') && window.matchMedia('(prefers-color-scheme: dark)').matches) || (document.querySelector('html[class*=dark], html[data-dark-theme*=dark], html[data-theme*=dark], html[data-color-mode*=dark], body[class*=dark]')) || (window.getComputedStyle(document.body).backgroundColor === 'rgb(0, 0, 0)') || (getColorValue(document.body) > 0 && getColorValue(document.body) < 898989) || (getColorValue(document.lastElementChild) > 0 && getColorValue(document.lastElementChild) < 898989) || (window.getComputedStyle(document.body).backgroundColor === 'rgba(0, 0, 0, 0)' && window.getComputedStyle(document.lastElementChild).backgroundColor === 'rgb(0, 0, 0)')) {
// 如果是在资源页 且 浏览器为暗黑模式,或 html/body 元素包含 dark 标识,或底色为黑色 (等于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
@@ -455,8 +455,8 @@
// 用来解决一些 CSS 加载缓慢的网站,可能会出现没有正确排除的问题,在没有找到更好的办法之前,先这样凑活着用
setTimeout(function(){
console.log('[护眼模式] html:', window.getComputedStyle(document.lastElementChild).backgroundColor, 'body:', window.getComputedStyle(document.body).backgroundColor)
if ((document.querySelector('head>meta[name="color-scheme"],head>link[href^="resource:"]') && window.matchMedia('(prefers-color-scheme: dark)').matches) || window.getComputedStyle(document.body).backgroundColor === 'rgb(0, 0, 0)' || getColorValue(document.body) > 0 && getColorValue(document.body) < 898989 || getColorValue(document.lastElementChild) > 0 && getColorValue(document.lastElementChild) < 898989 || window.getComputedStyle(document.body).backgroundColor === 'rgba(0, 0, 0, 0)' && window.getComputedStyle(document.lastElementChild).backgroundColor === 'rgb(0, 0, 0)') {
// 如果是在资源页 且 浏览器为暗黑模式,或底色为黑色 (等于0,0,0) 或深色 (小于 89,89,89),就停用本脚本滤镜
if ((document.querySelector('head>meta[name="color-scheme"],head>link[href^="resource:"]') && window.matchMedia('(prefers-color-scheme: dark)').matches) || (document.querySelector('html[class*=dark], html[data-dark-theme*=dark], html[data-theme*=dark], html[data-color-mode*=dark], body[class*=dark]')) || (window.getComputedStyle(document.body).backgroundColor === 'rgb(0, 0, 0)') || (getColorValue(document.body) > 0 && getColorValue(document.body) < 898989) || (getColorValue(document.lastElementChild) > 0 && getColorValue(document.lastElementChild) < 898989) || (window.getComputedStyle(document.body).backgroundColor === 'rgba(0, 0, 0, 0)' && window.getComputedStyle(document.lastElementChild).backgroundColor === 'rgb(0, 0, 0)')) {
// 如果是在资源页 且 浏览器为暗黑模式,或 html/body 元素包含 dark 标识,或底色为黑色 (等于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