From 95cfa42155ba514cebceb54fbab199a795e9af57 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Sun, 8 Sep 2024 21:09:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20[=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E7=94=A8=E6=88=B7]=20=E5=8A=9F=E8=83=BD=E5=9C=A8=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E6=97=A0=E8=AF=84=E8=AE=BA=E7=9A=84=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?(=E6=97=A0=E6=84=9F=E7=9F=A5);=20=E7=A7=BB=E9=99=A4=20[?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=99=BB=E5=BD=95=E5=BC=B9=E7=AA=97]=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BB=A3=E7=A0=81(=E5=8F=8D=E6=AD=A3?= =?UTF-8?q?=E4=B9=9F=E6=B2=A1=E4=BB=80=E4=B9=88=E6=84=8F=E4=B9=89=E4=BA=86?= =?UTF-8?q?=EF=BC=8C=E7=95=99=E7=9D=80=E5=8F=8D=E8=80=8C=E6=98=AF=E4=B8=8D?= =?UTF-8?q?=E6=98=AF=E8=A2=AB=E9=97=AE...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zhihu-Enhanced.user.js | 39 ++------------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/Zhihu-Enhanced.user.js b/Zhihu-Enhanced.user.js index ccb3edd..8667ce4 100644 --- a/Zhihu-Enhanced.user.js +++ b/Zhihu-Enhanced.user.js @@ -3,7 +3,7 @@ // @name:zh-CN 知乎增强 // @name:zh-TW 知乎增強 // @name:en Zhihu enhancement -// @version 2.3.8 +// @version 2.3.9 // @author X.I.U // @description 屏蔽指定类别(视频、盐选、文章、想法、关注[赞同了XX/关注了XX]等等)、屏蔽用户、屏蔽关键词、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回到顶部(右键两侧)、区分问题文章、移除高亮链接、净化搜索热门、净化标题消息、展开问题描述、显示问题作者、默认高清原图(无水印)、置顶显示时间、完整问题时间、直达问题按钮、默认站外直链... // @description:zh-TW 屏蔽指定類別(視頻、鹽選、文章、想法、關注[贊同了XX/關注了XX]等等)、屏蔽用戶、屏蔽關鍵詞、默認收起回答、快捷收起回答/評論、快捷回到頂部、區分問題文章、移除高亮鏈接、默認高清原圖(無水印)、默認站外直鏈... @@ -657,7 +657,7 @@ function blockUsers(type) { for (const target of mutation.addedNodes) { if (target.nodeType != 1) return //console.log(target, target.className) - if (target.className && (target.className.indexOf('css-') == 0 || target.style == 'opacity: 1;')) { + if (target.tagName == 'DIV' && target.className && (target.className.indexOf('css-') == 0 || target.style == 'opacity: 1;')) { const item = target.querySelector('.MemberButtonGroup.ProfileButtonGroup.HoverCard-buttons'), item1 = target.querySelector('img.Avatar+div span.UserLink>a.UserLink-link[data-za-detail-view-element_name=User]'); if (item1) { @@ -1178,40 +1178,6 @@ function questionRichTextMore() { } -// 知乎免登录 -function removeLogin() { - const removeLoginModal = (mutationsList, observer) => { - for (const mutation of mutationsList) { - for (const target of mutation.addedNodes) { - if (target.nodeType != 1) return - if (target.querySelector('.signFlowModal')) { - let button = target.querySelector('.Button.Modal-closeButton.Button--plain'); - if (button) button.click(); - } else if (getXpath('//button[text()="立即登录/注册"]',target)) { - target.remove(); - } - } - } - }; - - // 未登录时才会监听并移除登录弹窗 - if(location.hostname === 'zhuanlan.zhihu.com') { // 如果是文章页 - if (!document.querySelector('.ColumnPageHeader-profile>.AppHeader-menu')) { // 未登录 - const observer = new MutationObserver(removeLoginModal); - observer.observe(document, { childList: true, subtree: true }); - if (getXpath('//button[text()="登录/注册"]')) getXpath('//button[text()="登录/注册"]').outerHTML = '登录/注册'; // [登录] 按钮跳转至登录页面 - } - } else { // 不是文章页 - if (!document.querySelector('.AppHeader-profile>.AppHeader-menu')) { // 未登录 - const observer = new MutationObserver(removeLoginModal); - observer.observe(document, { childList: true, subtree: true }); - document.lastElementChild.appendChild(document.createElement('style')).textContent = '.Question-mainColumnLogin, button.AppHeader-login {display: none !important;}'; // 屏蔽问题页中间的登录提示 - if (getXpath('//button[text()="登录/注册"]')) getXpath('//button[text()="登录/注册"]').outerHTML = '登录/注册'; // [登录] 按钮跳转至登录页面 - } - } -} - - // 净化标题消息 function cleanTitles() { if (!menu_value('menu_cleanTitles')) return @@ -1518,7 +1484,6 @@ function blockHotOther() { } }) - removeLogin(); // 移除登录弹窗,Violentmonkey 不能延迟执行这个 cleanTitles(); // 净化标题消息,不能延迟执行 // Violentmonkey 比 Tampermonkey 加载更早,会导致一些元素还没加载,因此需要延迟一会儿 // Tampermonkey 4.18.0 版本可能需要延迟一会执行