Skip to content

Commit d1a2567

Browse files
committed
新增 屏蔽首页想法(Beta)
1 parent 9b59972 commit d1a2567

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

Zhihu-Enhanced.user.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @name:zh-CN 知乎增强
44
// @name:zh-TW 知乎增強
55
// @name:en Zhihu enhancement
6-
// @version 2.2.13
6+
// @version 2.2.14
77
// @author X.I.U
88
// @description 移除登录弹窗、屏蔽首页视频、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回到顶部(右键两侧)、屏蔽用户、屏蔽关键词、移除高亮链接、屏蔽盐选内容/热榜杂项、净化搜索热门、净化标题消息、展开问题描述、显示问题作者、置顶显示时间、完整问题时间、区分问题文章、直达问题按钮、默认高清原图、默认站外直链
99
// @description:zh-TW 移除登錄彈窗、屏蔽首頁視頻、默認收起回答、快捷收起回答/評論、快捷回到頂部、屏蔽用戶、屏蔽關鍵詞、移除高亮鏈接、屏蔽鹽選內容、淨化搜索熱門、淨化標題消息、置頂顯示時間、完整問題時間、區分問題文章、默認高清原圖、默認站外直鏈...
@@ -42,6 +42,7 @@ var menu_ALL = [
4242
['menu_blockType', '屏蔽指定类别 (视频/文章等)', '勾选 = 屏蔽该类别的信息流', ''],
4343
['menu_blockTypeVideo', '视频 [首页、搜索页、问题页]', '视频(首页、搜索页、问题页)', true],
4444
['menu_blockTypeArticle', '文章 [首页、搜索页]', '文章(首页、搜索页)', false],
45+
['menu_blockTypePin', '想法 [首页]', '想法(首页)', false],
4546
['menu_blockTypeTopic', '话题 [搜索页]', '话题(搜索页)', false],
4647
['menu_blockTypeSearch', '杂志文章、盐选专栏、相关搜索等 [搜索页]', '相关搜索、杂志、盐选等(搜索页)', false],
4748
['menu_blockYanXuan', '盐选内容 [问题页]', '盐选内容(问题页)', false],
@@ -72,8 +73,8 @@ function registerMenuCommand() {
7273
} else if (menu_ALL[i][0] === 'menu_customBlockKeywords') {
7374
if (menu_value('menu_blockKeywords')) menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function(){customBlockKeywords()});
7475
} else if (menu_ALL[i][0] === 'menu_blockType') {
75-
menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function(){menu_setting('checkbox', menu_ALL[i][1], menu_ALL[i][2], true, [menu_ALL[i+1], menu_ALL[i+2], menu_ALL[i+3], menu_ALL[i+4], menu_ALL[i+5], menu_ALL[i+6]])});
76-
} else if (menu_ALL[i][0] != 'menu_blockTypeVideo' && menu_ALL[i][0] != 'menu_blockTypeArticle' && menu_ALL[i][0] != 'menu_blockTypeTopic' && menu_ALL[i][0] != 'menu_blockTypeSearch' && menu_ALL[i][0] != 'menu_blockYanXuan' && menu_ALL[i][0] != 'menu_blockTypeLiveHot') {
76+
menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function(){menu_setting('checkbox', menu_ALL[i][1], menu_ALL[i][2], true, [menu_ALL[i+1], menu_ALL[i+2], menu_ALL[i+3], menu_ALL[i+4], menu_ALL[i+5], menu_ALL[i+6], menu_ALL[i+7]])});
77+
} else if (menu_ALL[i][0] != 'menu_blockTypeVideo' && menu_ALL[i][0] != 'menu_blockTypeArticle' && menu_ALL[i][0] != 'menu_blockTypePin' && menu_ALL[i][0] != 'menu_blockTypeTopic' && menu_ALL[i][0] != 'menu_blockTypeSearch' && menu_ALL[i][0] != 'menu_blockYanXuan' && menu_ALL[i][0] != 'menu_blockTypeLiveHot') {
7778
menu_ID[i] = GM_registerMenuCommand(`${menu_ALL[i][3]?'✅':'❌'} ${menu_ALL[i][1]}`, function(){menu_switch(`${menu_ALL[i][3]}`,`${menu_ALL[i][0]}`,`${menu_ALL[i][2]}`)});
7879
}
7980
}
@@ -890,7 +891,7 @@ function blockType(type) {
890891
let name;
891892
// 一开始加载的信息流 + 添加标签样式
892893
if (type === 'search') { // 搜索页
893-
if (!menu_value('menu_blockTypeVideo') && !menu_value('menu_blockTypeArticle') && !menu_value('menu_blockTypeTopic') && !menu_value('menu_blockTypeSearch')) return
894+
if (!menu_value('menu_blockTypeVideo') && !menu_value('menu_blockTypeArticle') && !menu_value('menu_blockTypePin') && !menu_value('menu_blockTypeTopic') && !menu_value('menu_blockTypeSearch')) return
894895
if (menu_value('menu_blockTypeSearch') && location.pathname === '/search') setTimeout(function(){document.querySelectorAll('.RelevantQuery').forEach((r)=>{r.parentElement.parentElement.hidden = true});}, 2000)
895896
name = 'h2.ContentItem-title a:not(.zhihu_e_toQuestion), a.KfeCollection-PcCollegeCard-link, h2.SearchTopicHeader-Title a'
896897
addSetInterval_(name);
@@ -900,7 +901,7 @@ function blockType(type) {
900901
name = '.VideoAnswerPlayer'
901902
document.querySelectorAll(name).forEach(function(item){blockType_(item);})
902903
} else { // 首页
903-
if (!menu_value('menu_blockTypeVideo') && !menu_value('menu_blockTypeArticle')) return
904+
if (!menu_value('menu_blockTypeVideo') && !menu_value('menu_blockTypeArticle') && !menu_value('menu_blockTypePin')) return
904905
if (menu_value('menu_blockTypeVideo')) document.lastChild.appendChild(document.createElement('style')).textContent = `.Card .ZVideoItem-video, .VideoAnswerPlayer video, nav.TopstoryTabs > a[aria-controls="Topstory-zvideo"] {display: none !important;}`;
905906
name = 'h2.ContentItem-title a:not(.zhihu_e_toQuestion)'
906907
document.querySelectorAll(name).forEach(function(item){blockType_(item);})
@@ -955,6 +956,8 @@ function blockType(type) {
955956
if (menu_value('menu_blockTypeVideo')) {findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').hidden = true;}
956957
} else if (titleA.href.indexOf('zhuanlan.zhihu.com') > -1) { // 如果是文章
957958
if (menu_value('menu_blockTypeArticle')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').hidden = true;
959+
} else if (titleA.href.indexOf('/pin/') > -1) { // 如果是想法
960+
if (menu_value('menu_blockTypePin')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').hidden = true;
958961
}
959962
}
960963
}
@@ -1342,7 +1345,7 @@ function topTime_publishTop(t, _this, _class) {
13421345
let temp_time = t.cloneNode(true);
13431346
temp_time.style.padding = '0px';
13441347
// 对于较短的回答,隐藏回答底部的时间
1345-
if (_this.offsetHeight < 400) t.style.display = 'none';
1348+
if (_this.offsetHeight < 600) t.style.display = 'none';
13461349
_this.querySelector('.' + _class).insertAdjacentElement('beforeEnd', temp_time);
13471350
}
13481351
}

0 commit comments

Comments
 (0)