Skip to content

Commit b852190

Browse files
committed
优化 [屏蔽用户]、[屏蔽关键词] 功能
1 parent f6bef2b commit b852190

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

Zhihu-Enhanced.user.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @name:en Zhihu enhancement
44
// @name:zh-CN 知乎增强
55
// @name:zh-TW 知乎增強
6-
// @version 1.9.8
6+
// @version 1.9.9
77
// @author X.I.U
88
// @description 移除登录弹窗、屏蔽首页视频、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回到顶部(右键两侧)、屏蔽用户、屏蔽关键词、移除高亮链接、屏蔽盐选内容、净化标题消息、展开问题描述、显示问题作者、置顶显示时间、完整问题时间、区分问题文章、直达问题按钮、默认高清原图、默认站外直链
99
// @description:en Remove the login popup, block the homepage video, close the answer by default, quickly close the answer/comment (both sides of the left button), quickly return to the top (both sides of the right button), block users, block keywords, remove highlighted links , Shield salt selection, purify title message, expand problem description, display problem author, display time on top, complete problem time, distinguish problem article, direct problem button, default high-definition original image, default off-site direct link
@@ -443,7 +443,7 @@ function blockUsers(type) {
443443
let item = item1.querySelector('.ContentItem.AnswerItem, .ContentItem.ArticleItem'); // 用户名所在元素
444444
if (item) {
445445
for (const keyword of menu_value('menu_customBlockUsers')) { // 遍历用户名黑名单
446-
if (item.dataset.zop.indexOf('authorName":"' + keyword + '",') > -1) { // 找到就删除该信息流
446+
if (keyword != '' && item.dataset.zop.indexOf('authorName":"' + keyword + '",') > -1) { // 找到就删除该信息流
447447
console.log(item.dataset.zop);
448448
item1.hidden = true;
449449
break;
@@ -467,7 +467,7 @@ function blockUsers(type) {
467467
let item = target.querySelector('.ContentItem.AnswerItem, .ContentItem.ArticleItem'); // 用户名所在元素
468468
if (item) {
469469
for (const keyword of menu_value('menu_customBlockUsers')) { // 遍历用户名黑名单
470-
if (item.dataset.zop.indexOf('authorName":"' + keyword + '",') > -1) { // 找到就删除该信息流
470+
if (keyword != '' && item.dataset.zop.indexOf('authorName":"' + keyword + '",') > -1) { // 找到就删除该信息流
471471
console.log(item.dataset.zop);
472472
target.hidden = true;
473473
break;
@@ -551,7 +551,7 @@ function blockUsers(type) {
551551
let item = item1.querySelector('.RichText.ztext.CopyrightRichText-richText b'); // 标题所在元素
552552
if (item) {
553553
for (const keyword of menu_value('menu_customBlockUsers')) { // 遍历关键词黑名单
554-
if (item.textContent === keyword) { // 找到就删除该信息流
554+
if (keyword != '' && item.textContent === keyword) { // 找到就删除该信息流
555555
console.log(item.textContent);
556556
item1.hidden = true;
557557
break;
@@ -575,7 +575,7 @@ function blockUsers(type) {
575575
let item = target.querySelector('.RichText.ztext.CopyrightRichText-richText b'); // 用户名所在元素
576576
if (item) {
577577
for (const keyword of menu_value('menu_customBlockUsers')) { // 遍历用户名黑名单
578-
if (item.textContent === keyword) { // 找到就删除该信息流
578+
if (keyword != '' && item.textContent === keyword) { // 找到就删除该信息流
579579
console.log(item.textContent);
580580
target.hidden = true;
581581
break;
@@ -829,8 +829,8 @@ function blockKeywords(type) {
829829
let keywords = menu_value('menu_customBlockKeywords');
830830
for (const text of texts) {
831831
for (const keyword of keywords) { // 遍历关键词黑名单
832-
if (text.indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该评论
833-
console.log(text);
832+
if (keyword != '' && text.indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该评论
833+
console.log('已屏蔽评论:' + text);
834834
content.textContent = '[该评论已屏蔽]';
835835
break;
836836
}
@@ -857,7 +857,7 @@ function blockKeywords(type) {
857857
if (item) {
858858
for (const keyword of menu_value('menu_customBlockKeywords')) { // 遍历关键词黑名单
859859
let text = item.content || item.textContent;
860-
if (text.toLowerCase().indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该信息流
860+
if (keyword != '' && text.toLowerCase().indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该信息流
861861
console.log(text);
862862
item1.hidden = true;
863863
item1.style.display = 'none';

0 commit comments

Comments
 (0)