修复 屏蔽视频后在首页按空格键滚动会播放视频的问题

This commit is contained in:
xiu2
2023-02-17 18:00:38 +08:00
parent 00ea51195e
commit e3de3a5302
+7 -7
View File
@@ -3,7 +3,7 @@
// @name:zh-CN 知乎增强
// @name:zh-TW 知乎增強
// @name:en Zhihu enhancement
// @version 2.2.5
// @version 2.2.6
// @author X.I.U
// @description 移除登录弹窗、屏蔽首页视频、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回到顶部(右键两侧)、屏蔽用户、屏蔽关键词、移除高亮链接、屏蔽盐选内容/热榜直播、净化搜索热门、净化标题消息、展开问题描述、显示问题作者、置顶显示时间、完整问题时间、区分问题文章、直达问题按钮、默认高清原图、默认站外直链
// @description:zh-TW 移除登錄彈窗、屏蔽首頁視頻、默認收起回答、快捷收起回答/評論、快捷回到頂部、屏蔽用戶、屏蔽關鍵詞、移除高亮鏈接、屏蔽鹽選內容、淨化搜索熱門、淨化標題消息、置頂顯示時間、完整問題時間、區分問題文章、默認高清原圖、默認站外直鏈...
@@ -888,12 +888,12 @@ function blockType(type) {
addSetInterval_(name);
} else if (type === 'question') { // 问题页
if (!menu_value('menu_blockTypeVideo')) return
document.lastChild.appendChild(document.createElement('style')).textContent = `.VideoAnswerPlayer, .VideoAnswerPlayer-video, .VideoAnswerPlayer-iframe {display: none !important;}`;
document.lastChild.appendChild(document.createElement('style')).textContent = `.VideoAnswerPlayer, .VideoAnswerPlayer video, .VideoAnswerPlayer-video, .VideoAnswerPlayer-iframe {display: none !important;}`;
name = '.VideoAnswerPlayer'
document.querySelectorAll(name).forEach(function(item){blockType_(item);})
} else { // 首页
if (!menu_value('menu_blockTypeVideo') && !menu_value('menu_blockTypeArticle')) return
if (menu_value('menu_blockTypeVideo')) document.lastChild.appendChild(document.createElement('style')).textContent = `.Card .ZVideoItem-video, nav.TopstoryTabs > a[aria-controls="Topstory-zvideo"] {display: none !important;}`;
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;}`;
name = 'h2.ContentItem-title a:not(.zhihu_e_toQuestion)'
document.querySelectorAll(name).forEach(function(item){blockType_(item);})
}
@@ -921,7 +921,7 @@ function blockType(type) {
if (location.pathname === '/search') { // 搜索页
if (location.search.indexOf('type=content') === -1) return // 仅限搜索页的 [综合]
if (titleA.href.indexOf('/zvideo/') > -1 || titleA.href.indexOf('video.zhihu.com') > -1) { // 如果是视频
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card').hidden = true;
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card').remove();
} else if (titleA.href.indexOf('zhuanlan.zhihu.com') > -1) { // 如果是文章
if (menu_value('menu_blockTypeArticle')) findParentElement(titleA, 'Card SearchResult-Card').hidden = true;
} else if (titleA.href.indexOf('/topic/') > -1) { // 如果是话题
@@ -933,13 +933,13 @@ function blockType(type) {
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'List-item').hidden = true;
} else { // 首页
if (titleA.href.indexOf('/zvideo/') > -1 || titleA.href.indexOf('video.zhihu.com') > -1) { // 如果是视频
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').hidden = true;
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').remove();
} else if (titleA.href.indexOf('/answer/') > -1) { // 如果是问题(视频回答)
if (findParentElement(titleA, 'ContentItem AnswerItem').querySelector('.VideoAnswerPlayer')) {
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').hidden = true;
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').remove();
}
} else if (titleA.href.indexOf('/education/video-course/') > -1) { // 如果是視頻課程
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').hidden = true;
if (menu_value('menu_blockTypeVideo')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').remove();
} else if (titleA.href.indexOf('zhuanlan.zhihu.com') > -1) { // 如果是文章
if (menu_value('menu_blockTypeArticle')) findParentElement(titleA, 'Card TopstoryItem TopstoryItem-isRecommend').hidden = true;
}