diff --git a/Zhihu-Enhanced.user.js b/Zhihu-Enhanced.user.js
index 4d48a31..b4c0e61 100644
--- a/Zhihu-Enhanced.user.js
+++ b/Zhihu-Enhanced.user.js
@@ -3,7 +3,7 @@
// @name:zh-CN 知乎增强
// @name:zh-TW 知乎增強
// @name:ru Улучшение Zhihu
-// @version 2.3.18
+// @version 2.3.19
// @author X.I.U
// @description A more personalized Zhihu experience~
// @description:zh-CN 移除登录弹窗、屏蔽指定类别(视频、盐选、文章、想法、关注[赞同/关注了XX]等)、屏蔽低赞/低评回答、屏蔽用户、屏蔽关键词、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回到顶部(右键两侧)、区分问题文章、移除高亮链接、净化搜索热门、净化标题消息、展开问题描述、显示问题作者、默认高清原图(无水印)、置顶显示时间、完整问题时间、直达问题按钮、默认站外直链...
@@ -36,8 +36,13 @@ var menu_ALL = [
['menu_collapsedAnswer', '一键收起回答/评论', '一键收起回答/评论', true],
['menu_collapsedNowAnswer', '快捷收起回答/评论 (点击两侧空白处)', '快捷收起回答/评论', true],
['menu_backToTop', '快捷回到顶部 (右键两侧空白处)', '快捷回到顶部', true],
- ['menu_blockLowUpvoteCount', '屏蔽低赞回答', '屏蔽低赞回答', ''],
- ['menu_blockLowCommentCount', '屏蔽低评回答', '屏蔽低评回答', ''],
+ ['menu_blockLowCount', '屏蔽低赞低评', '设置要屏蔽 低于多少赞同/评价 的回答(默认不需要留空即可)
(例如设置 0 则无人赞同/评价的回答会被屏蔽
(例如设置 20 则赞同/评价数量低于 20 的回答会被屏蔽
(修改后,后续加载的回答会立即生效,但不影响当前网页已有内容', ''],
+ ['menu_blockLowUpvoteCount', '最低赞同数 [首页]', '最低赞同数(首页)', ''],
+ ['menu_blockLowCommentCount', '最低评价数 [首页]', '最低评价数(首页)', ''],
+ ['menu_blockLowUpvoteCountQuestion', '最低赞同数 [问题页]', '最低赞同数(问题页)', ''],
+ ['menu_blockLowCommentCountQuestion', '最低评价数 [问题页]', '最低评价数(问题页)', ''],
+ ['menu_blockLowUpvoteCountFollow', '最低赞同数 [关注页]', '最低赞同数(关注页)', ''],
+ ['menu_blockLowCommentCountFollow', '最低评价数 [关注页]', '最低评价数(关注页)', ''],
['menu_blockUsers', '屏蔽指定用户', '屏蔽指定用户', true],
['menu_customBlockUsers', '自定义屏蔽用户', '自定义屏蔽用户', ['故事档案局', '盐选推荐', '盐选科普', '盐选成长计划', '知乎盐选会员', '知乎盐选创作者', '盐选心理', '盐选健康必修课', '盐选奇妙物语', '盐选生活馆', '盐选职场', '盐选文学甄选', '盐选作者小管家', '盐选博物馆', '盐选点金', '盐选测评室', '盐选科技前沿', '盐选会员精品']],
['menu_blockKeywords', '屏蔽指定关键词', '屏蔽指定关键词', true],
@@ -75,10 +80,11 @@ function registerMenuCommand() {
}
for (let i=0;i${tips}
`
if (line) _br = '
'
for (let i=0; i${menu[i][1]}:${_br}`
+ } else if (GM_getValue(menu[i][0])) {
_html += `${_br}`
} else {
_html += `${_br}`
@@ -146,14 +156,20 @@ function menu_setting(type, title, tips, line, menu) {
_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').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);}});
})
+ // 输入框 变化事件
+ doc.querySelectorAll('input[type=text]').forEach(function (checkBox) {
+ checkBox.onchange = function(){GM_setValue(this.name, this.value);};
+ })
}, 100)
}
@@ -429,37 +445,27 @@ function isElementInViewport_(el) {
}
-// 自定义屏蔽低赞/低评回答
-function customBlockLowCount(menu, info) {
- let newCount = prompt(info, menu_value(menu));
- if (newCount == '' || /^(0|[1-9]\d*)$/.test(newCount)) { // 检查是否是有效整数
- GM_setValue(menu, newCount);
- registerMenuCommand(); // 重新注册脚本菜单
- }
-};
-
-
// 屏蔽低赞/低评回答
function blockLowCount(type) {
switch(type) {
case 'index':
- blockLowCount_('.Card.TopstoryItem.TopstoryItem-isRecommend', 'Card TopstoryItem TopstoryItem-isRecommend');
+ blockLowCount_('.Card.TopstoryItem.TopstoryItem-isRecommend', 'Card TopstoryItem TopstoryItem-isRecommend', 'menu_blockLowUpvoteCount', 'menu_blockLowCommentCount');
break;
case 'follow':
- blockLowCount_('.Card.TopstoryItem.TopstoryItem-isFollow', 'Card TopstoryItem TopstoryItem-isFollow');
+ blockLowCount_('.Card.TopstoryItem.TopstoryItem-isFollow', 'Card TopstoryItem TopstoryItem-isFollow', 'menu_blockLowUpvoteCountFollow', 'menu_blockLowCommentCountFollow');
break;
case 'question':
- blockLowCount_('.List-item', 'List-item');
+ blockLowCount_('.List-item', 'List-item', 'menu_blockLowUpvoteCountQuestion', 'menu_blockLowCommentCountQuestion');
break;
}
- function blockLowCount_(className1, className2) {
+ function blockLowCount_(className1, className2, menuUpvote, menuComment) {
// 前几条因为是直接加载的,而不是动态插入网页的,所以需要单独判断
function blockLowCount_now() {
document.querySelectorAll(className1).forEach(function(item1){
- blockLowCount_1(item1,'menu_blockLowUpvoteCount','meta[itemprop=upvoteCount]');
- blockLowCount_1(item1,'menu_blockLowCommentCount','meta[itemprop=commentCount]');
+ blockLowCount_1(item1,menuUpvote,'meta[itemprop=upvoteCount]');
+ blockLowCount_1(item1,menuComment,'meta[itemprop=commentCount]');
})
}
@@ -474,8 +480,8 @@ function blockLowCount(type) {
for (const target of mutation.addedNodes) {
if (target.nodeType != 1) return
if (target.className === className2) {
- blockLowCount_1(target,'menu_blockLowUpvoteCount','meta[itemprop=upvoteCount]');
- blockLowCount_1(target,'menu_blockLowCommentCount','meta[itemprop=commentCount]');
+ blockLowCount_1(target,menuUpvote,'meta[itemprop=upvoteCount]');
+ blockLowCount_1(target,menuComment,'meta[itemprop=commentCount]');
}
}
}
@@ -486,14 +492,14 @@ function blockLowCount(type) {
function blockLowCount_1(item1, menu, css) {
- if (menu_value(menu)) {
+ if (GM_getValue(menu)) {
let item = item1.querySelector(css);
//console.log(item)
- if (item && item.content && Number(item.content) < Number(menu_value(menu))) {
- if (menu == 'menu_blockLowUpvoteCount') {
- console.log('已屏蔽低赞回答:', item.content + '<' + menu_value(menu), item1);
+ if (item && item.content && Number(item.content) < Number(GM_getValue(menu))) {
+ if (menu.indexOf('Upvote') !== -1) {
+ console.log('已屏蔽低赞回答:', item.content + '<' + GM_getValue(menu), item1, type);
} else {
- console.log('已屏蔽低评回答:', item.content + '<' + menu_value(menu), item1);
+ console.log('已屏蔽低评回答:', item.content + '<' + GM_getValue(menu), item1, type);
}
item1.hidden = true;
item1.style.display = 'none';
@@ -1716,7 +1722,7 @@ function switchHome() {
blockKeywords('index'); // 屏蔽指定关键词
blockHotOther(); // 屏蔽热榜杂项
} else if (location.pathname == '/follow') { // 关注
- //blockLowCount('follow'); // 屏蔽低赞/低评回答
+ blockLowCount('follow'); // 屏蔽低赞/低评回答
blockUsers('follow'); // 屏蔽指定用户
blockKeywords('follow'); // 屏蔽指定关键词
blockType(); // 屏蔽指定类别(视频/文章等)