From abf33612120c44328e16c51cee9ee2e3008b0955 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Sun, 20 Jun 2021 16:37:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DarkMode.user.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/DarkMode.user.js b/DarkMode.user.js index 2355f03..47397fb 100644 --- a/DarkMode.user.js +++ b/DarkMode.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 护眼模式 -// @version 1.0.4 +// @version 1.0.5 // @author X.I.U // @description 最简单的全网通用护眼模式、夜间模式、暗黑模式 // @match *://*/* @@ -148,9 +148,9 @@ style += style_31; break; } - style_Add.innerHTML = style; - //document.lastChild.appendChild(document.createElement("style")).textContent = style; - if (document.head) { + //style_Add.innerHTML = style; + document.lastChild.appendChild(document.createElement("style")).textContent = style; + /*if (document.head) { document.head.appendChild(style_Add); } else { // 为了避免脚本运行的时候 head 还没加载导致报错 let timer = setInterval(function(){ @@ -159,18 +159,19 @@ clearInterval(timer); } }, 1); - } + }*/ // 为了避免 body 还没加载导致无法检查是否设置背景颜色的备用措施 //if (!grayLevel) { setTimeout(function(){ if (document.body) { console.log(window.getComputedStyle(document.body).backgroundColor) - let rgbValueArry = window.getComputedStyle(document.body).backgroundColor.replace ('rgb(', '').replace ('rgba(', '').replace (')', '').split (', '), - style_Add1 = document.createElement('style'); + let rgbValueArry = window.getComputedStyle(document.body).backgroundColor.replace ('rgb(', '').replace ('rgba(', '').replace (')', '').split (', '); + //style_Add1 = document.createElement('style'); if (rgbValueArry [0] + rgbValueArry [1] + rgbValueArry [2] === "000") { - style_Add1.innerHTML = style_00; - document.head.appendChild(style_Add1); + //style_Add1.innerHTML = style_00; + //document.head.appendChild(style_Add1); + document.lastChild.appendChild(document.createElement("style")).textContent = style_00; } } }, 100);