修复 [屏蔽关键词] 对搜索页后续加载失效的问题; 修复 [屏蔽相关搜索]

This commit is contained in:
xiu2
2023-10-29 12:18:10 +08:00
parent 47dc4b15bb
commit 3ea8b30c53
+15 -5
View File
@@ -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) {