Skip to content

Commit e8c0117

Browse files
committed
更新 [屏蔽首页视频] 功能
1 parent 479cef4 commit e8c0117

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

Zhihu-Enhanced.user.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 知乎增强
3-
// @version 1.8.6
3+
// @version 1.8.7
44
// @author X.I.U
55
// @description 移除登录弹窗、屏蔽首页视频、默认收起回答、快捷收起当前回答/评论(左键两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽用户 (发布的内容)、屏蔽关键词(标题/评论)、移除高亮链接、屏蔽盐选内容、净化标题消息、展开问题描述、置顶显示时间、完整问题时间、区分问题文章、直达问题按钮、默认高清原图、默认站外直链
66
// @match *://www.zhihu.com/*
@@ -147,9 +147,9 @@ function getCollapsedAnswerObserver() {
147147
if (!mutation.target.classList.contains('RichContent')) continue
148148
for (const addedNode of mutation.addedNodes) {
149149
if (addedNode.nodeType != Node.ELEMENT_NODE) continue
150-
//console.log(addedNode, addedNode.offsetHeight)
150+
console.log(addedNode, addedNode.offsetHeight)
151151
if (addedNode.className == 'RichContent-inner' && addedNode.offsetHeight < 400) return
152-
//console.log(addedNode.offsetHeight)
152+
console.log(addedNode.offsetHeight)
153153
const button = addedNode.querySelector('.ContentItem-actions.Sticky [data-zop-retract-question]');
154154
if (button) {
155155
mutation.target.setAttribute('script-collapsed', '');
@@ -854,10 +854,10 @@ function blockKeywords(type) {
854854
function blockType(type) {
855855
let name;
856856
// 一开始加载的信息流 + 添加标签样式
857-
if (type === 'search') {
857+
if (type === 'search') { // 搜索页
858858
if (!menu_value('menu_blockTypeVideo') && !menu_value('menu_blockTypeArticle') && !menu_value('menu_blockTypeTopic') && !menu_value('menu_blockTypeSearch')) return
859859
if (menu_value('menu_blockTypeSearch') && location.pathname === '/search') setTimeout(function(){document.querySelector('.RelevantQuery').parentElement.parentElement.hidden = true;;}, 1000)
860-
name = 'h2.ContentItem-title a, a.KfeCollection-PcCollegeCard-link, h2.SearchTopicHeader-Title a'
860+
name = 'h2.ContentItem-title a:not(.zhihu_e_toQuestion), a.KfeCollection-PcCollegeCard-link, h2.SearchTopicHeader-Title a'
861861
addSetInterval_(name);
862862
} else if (type === 'question') { // 问题页
863863
if (!menu_value('menu_blockTypeVideo')) return
@@ -866,9 +866,8 @@ function blockType(type) {
866866
document.querySelectorAll(name).forEach(function(item){blockType_(item);})
867867
} else { // 首页
868868
if (!menu_value('menu_blockTypeVideo') && !menu_value('menu_blockTypeArticle')) return
869-
// 移除相关搜索
870-
if (menu_value('menu_blockTypeVideo')) document.lastChild.appendChild(document.createElement('style')).textContent = `nav.TopstoryTabs > a[aria-controls="Topstory-zvideo"] {display: none !important;}`;
871-
name = 'h2.ContentItem-title a'
869+
if (menu_value('menu_blockTypeVideo')) document.lastChild.appendChild(document.createElement('style')).textContent = `.Card .ZVideoItem-video {display: none !important;}`;
870+
name = 'h2.ContentItem-title a:not(.zhihu_e_toQuestion)'
872871
document.querySelectorAll(name).forEach(function(item){blockType_(item);})
873872
}
874873

@@ -891,9 +890,10 @@ function blockType(type) {
891890

892891
function blockType_(titleA) {
893892
if (!titleA) return // 判断是否为真
893+
console.log(titleA.href)
894894
if (location.pathname === '/search') { // 搜索页
895895
if (location.search.indexOf('type=content') === -1) return // 仅限搜索页的 [综合]
896-
if (titleA.href.indexOf('/zvideo/') > -1) { // 如果是视频
896+
if (titleA.href.indexOf('/zvideo/') > -1 || titleA.href.indexOf('video.zhihu.com') > -1) { // 如果是视频
897897
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card').hidden = true;
898898
} else if (titleA.href.indexOf('zhuanlan.zhihu.com') > -1) { // 如果是文章
899899
if (menu_value('menu_blockTypeArticle')) findParentElement(titleA, 'Card SearchResult-Card').hidden = true;
@@ -905,14 +905,14 @@ function blockType(type) {
905905
} else if (location.pathname.indexOf('/question/') > -1) { // 问题页
906906
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'List-item').hidden = true;
907907
} else { // 首页
908-
if (titleA.href.indexOf('/zvideo/') > -1) { // 如果是视频
909-
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem--old TopstoryItem-isRecommend').hidden = true;
908+
if (titleA.href.indexOf('/zvideo/') > -1 || titleA.href.indexOf('video.zhihu.com') > -1) { // 如果是视频
909+
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').hidden = true;
910910
} else if (titleA.href.indexOf('/answer/') > -1) { // 如果是问题(视频回答)
911911
if (findParentElement(titleA, 'ContentItem AnswerItem').querySelector('.VideoAnswerPlayer')) {
912-
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem--old TopstoryItem-isRecommend').hidden = true;
912+
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').hidden = true;
913913
}
914914
} else if (titleA.href.indexOf('zhuanlan.zhihu.com') > -1) { // 如果是文章
915-
if (menu_value('menu_blockTypeArticle')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem--old TopstoryItem-isRecommend').hidden = true;
915+
if (menu_value('menu_blockTypeArticle')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').hidden = true;
916916
}
917917
}
918918
}

0 commit comments

Comments
 (0)