From 4dab00ec649c77374a7a094b0069a0c81060559d Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Wed, 13 Aug 2025 21:31:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20[=E5=AE=BD=E5=B1=8F?= =?UTF-8?q?=E6=98=BE=E7=A4=BA]=20=E8=AE=BE=E7=BD=AE=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zhihu-Beautification.user.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Zhihu-Beautification.user.js b/Zhihu-Beautification.user.js index 5280629..cc90622 100644 --- a/Zhihu-Beautification.user.js +++ b/Zhihu-Beautification.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 知乎美化 -// @version 1.5.16 +// @version 1.5.17 // @author X.I.U // @description 宽屏显示、暗黑模式(4种)、暗黑模式跟随浏览器、屏蔽首页活动广告、隐藏文章开头大图、调整图片最大高度、向下翻时自动隐藏顶栏 // @match *://www.zhihu.com/* @@ -138,8 +138,10 @@ .zhihuE_SettingRoot .zhihuE_SettingHeader {padding: 10px 20px;color: #fff;font-weight: bold;background-color: #3994ff;border-radius: 3px 3px 0 0;} .zhihuE_SettingRoot .zhihuE_SettingMain {padding: 10px 20px;border-radius: 0 0 3px 3px;} .zhihuE_SettingHeader span {float: right;cursor: pointer;} -.zhihuE_SettingMain input {margin: 10px 6px 10px 0;cursor: pointer;vertical-align:middle} -.zhihuE_SettingMain label {margin-right: 20px;user-select: none;cursor: pointer;vertical-align:middle} +.zhihuE_SettingMain input {margin: 10px 6px 10px 0;vertical-align:middle;} +.zhihuE_SettingMain input[type=text] {margin: 5px 6px 5px 0;padding-block: 0;} +.zhihuE_SettingMain input[name=zhihuE_Setting_Checkbox] {cursor: pointer;} +.zhihuE_SettingMain label {margin-right: 20px;user-select: none;cursor: pointer;vertical-align:middle;} .zhihuE_SettingMain hr {border: 0.5px solid #f4f4f4;} [data-theme="dark"] .zhihuE_SettingRoot {color: #adbac7;background-color: #343A44;} [data-theme="dark"] .zhihuE_SettingHeader {color: #d0d0d0;background-color: #2D333B;} @@ -150,7 +152,7 @@ if (line) _br = '
' for (let i=0; i${menu[i][2]}:${_br}` + _html += `${_br}` } else if (GM_getValue(menu[i][0])) { _html += `${_br}` } else { @@ -160,15 +162,20 @@ _html += `` document.body.insertAdjacentHTML('beforeend', _html); // 插入网页末尾 setTimeout(function() { // 延迟 100 毫秒,避免太快 + const doc = document.querySelector('.zhihuE_SettingBackdrop_1'); + if (!doc) return // 关闭按钮 点击事件 - document.querySelector('.zhihuE_SettingClose').onclick = function(){this.parentElement.parentElement.parentElement.remove();document.querySelector('.zhihuE_SettingStyle').remove();} + doc.querySelector('.zhihuE_SettingClose').onclick = function(){this.parentElement.parentElement.parentElement.remove();document.querySelector('.zhihuE_SettingStyle').remove();} // 点击周围空白处 = 点击关闭按钮 - document.querySelector('.zhihuE_SettingBackdrop_2').onclick = function(event){if (event.target == this) {document.querySelector('.zhihuE_SettingClose').click();};} + doc.querySelector('.zhihuE_SettingBackdrop_2').onclick = function(event){if (event.target == this) {document.querySelector('.zhihuE_SettingClose').click();};} // 复选框 点击事件 - document.getElementsByName('zhihuE_Setting_Checkbox').forEach(function (checkBox) { + doc.querySelectorAll('input[name=zhihuE_Setting_Checkbox]').forEach(function (checkBox) { checkBox.addEventListener('click', function(){if (this.checked) {GM_setValue(this.value, true);} else {GM_setValue(this.value, false);}}); }) - document.getElementsByName('menu_widescreenDisplayWidth')[0].onchange = function(){GM_setValue(this.name, this.value);}; + // 输入框 变化事件 + doc.querySelectorAll('input[type=text]').forEach(function (checkBox) { + checkBox.onchange = function(){GM_setValue(this.name, this.value);}; + }) }, 100) }