From 3ea8b30c53a819a265c9b9b251025611eb2447fe Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Sun, 29 Oct 2023 12:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20[=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E8=AF=8D]=20=E5=AF=B9=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E9=A1=B5=E5=90=8E=E7=BB=AD=E5=8A=A0=E8=BD=BD=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98;=20=E4=BF=AE=E5=A4=8D=20[=E5=B1=8F?= =?UTF-8?q?=E8=94=BD=E7=9B=B8=E5=85=B3=E6=90=9C=E7=B4=A2]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zhihu-Enhanced.user.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Zhihu-Enhanced.user.js b/Zhihu-Enhanced.user.js index fe4cc0f..2c9cf60 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.2.12 +// @version 2.2.13 // @author X.I.U // @description 移除登录弹窗、屏蔽首页视频、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回到顶部(右键两侧)、屏蔽用户、屏蔽关键词、移除高亮链接、屏蔽盐选内容/热榜杂项、净化搜索热门、净化标题消息、展开问题描述、显示问题作者、置顶显示时间、完整问题时间、区分问题文章、直达问题按钮、默认高清原图、默认站外直链 // @description:zh-TW 移除登錄彈窗、屏蔽首頁視頻、默認收起回答、快捷收起回答/評論、快捷回到頂部、屏蔽用戶、屏蔽關鍵詞、移除高亮鏈接、屏蔽鹽選內容、淨化搜索熱門、淨化標題消息、置頂顯示時間、完整問題時間、區分問題文章、默認高清原圖、默認站外直鏈... @@ -816,7 +816,11 @@ function blockKeywords(type) { for (const mutation of mutationsList) { for (const target of mutation.addedNodes) { if (target.nodeType != 1) return - if (target.className === 'Card SearchResult-Card' && (target.dataset.zaDetailViewPathModule === 'AnswerItem' || target.dataset.zaDetailViewPathModule === 'PostItem')) {blockKeywords_1(target, 'a[data-za-detail-view-id]');} + //console.log(target) + if (target.tagName === 'DIV' && target.className === '') { + let tt = target.querySelector('div[class="Card SearchResult-Card"][data-za-detail-view-path-module="AnswerItem"], div[class="Card SearchResult-Card"][data-za-detail-view-path-module="PostItem"]') + if (tt) {blockKeywords_1(target.childNodes[0], 'a[data-za-detail-view-id]');} + } } } }; @@ -868,6 +872,7 @@ function blockKeywords(type) { if (item) { for (const keyword of menu_value('menu_customBlockKeywords')) { // 遍历关键词黑名单 let text = item.content || item.textContent; + //console.log(text,keyword) if (keyword != '' && text.toLowerCase().indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该信息流 console.log('已屏蔽:' + text); item1.hidden = true; @@ -886,7 +891,7 @@ function blockType(type) { // 一开始加载的信息流 + 添加标签样式 if (type === 'search') { // 搜索页 if (!menu_value('menu_blockTypeVideo') && !menu_value('menu_blockTypeArticle') && !menu_value('menu_blockTypeTopic') && !menu_value('menu_blockTypeSearch')) return - if (menu_value('menu_blockTypeSearch') && location.pathname === '/search') setTimeout(function(){document.querySelector('.RelevantQuery').parentElement.parentElement.hidden = true;}, 2000) + if (menu_value('menu_blockTypeSearch') && location.pathname === '/search') setTimeout(function(){document.querySelectorAll('.RelevantQuery').forEach((r)=>{r.parentElement.parentElement.hidden = true});}, 2000) name = 'h2.ContentItem-title a:not(.zhihu_e_toQuestion), a.KfeCollection-PcCollegeCard-link, h2.SearchTopicHeader-Title a' addSetInterval_(name); } else if (type === 'question') { // 问题页 @@ -906,7 +911,12 @@ function blockType(type) { for (const mutation of mutationsList) { for (const target of mutation.addedNodes) { if (target.nodeType != 1) return - blockType_(target.querySelector(name)); + if (target.className === "Card SearchResult-Card" && target.dataset.zaDetailViewPathModule === undefined) { + // 移除相关搜索 + if (menu_value('menu_blockTypeSearch') && location.pathname === '/search' && location.search.indexOf('type=content') > -1) target.hidden = true; + } else { + blockType_(target.querySelector(name)); + } } } }); @@ -915,7 +925,7 @@ function blockType(type) { window.addEventListener('urlchange', function(){ addSetInterval_(name); // 移除相关搜索 - if (menu_value('menu_blockTypeSearch') && location.pathname === '/search' && location.search.indexOf('type=content') > -1) setTimeout(function(){document.querySelector('.RelevantQuery').parentElement.parentElement.hidden = true;}, 1500) + if (menu_value('menu_blockTypeSearch') && location.pathname === '/search' && location.search.indexOf('type=content') > -1) setTimeout(function(){document.querySelectorAll('.RelevantQuery').forEach((r)=>{r.parentElement.parentElement.hidden = true});}, 1500) }) function blockType_(titleA) {