From 7d91824a774d42d438534a56d798e6fae767822c Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Tue, 22 Jun 2021 14:34:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20[=E6=8E=92=E9=99=A4?= =?UTF-8?q?=E8=87=AA=E5=B8=A6=E6=9A=97=E9=BB=91=E6=A8=A1=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E7=BD=91=E9=A1=B5=20(beta)]=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DarkMode.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DarkMode.user.js b/DarkMode.user.js index 28c87b9..e597b2c 100644 --- a/DarkMode.user.js +++ b/DarkMode.user.js @@ -146,6 +146,7 @@ // 为了避免 body 还没加载导致无法检查是否设置背景颜色 let timer = setInterval(function(){ // 每 10 毫秒检查一下 body 是否已存在(onload 太晚了,只能这么干) if (document.body) { + clearInterval(timer); // 取消定时器(每 10 毫秒一次的) setTimeout(function(){ // 为了避免太快 body 的 CSS 还没加载上,先延迟 100 毫秒(缺点就是可能会出现短暂一闪而过的暗黑滤镜) console.log(window.getComputedStyle(document.lastChild).backgroundColor, window.getComputedStyle(document.body).backgroundColor) if (window.getComputedStyle(document.body).backgroundColor === 'rgba(0, 0, 0, 0)' && window.getComputedStyle(document.lastChild).backgroundColor === 'rgba(0, 0, 0, 0)') { @@ -158,7 +159,6 @@ document.getElementById('XIU2DarkMode').remove(); } } - clearInterval(timer); }, 100); } }, 10);