Skip to content

Commit 36c1f32

Browse files
committed
修复 在 Violentmonkey 中首页无法切换为推荐的问题
1 parent 8cdf44b commit 36c1f32

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Zhihu-Enhanced.user.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @name:zh-CN 知乎增强
44
// @name:zh-TW 知乎增強
55
// @name:ru Улучшение Zhihu
6-
// @version 2.3.19
6+
// @version 2.3.20
77
// @author X.I.U
88
// @description A more personalized Zhihu experience~
99
// @description:zh-CN 移除登录弹窗、屏蔽指定类别(视频、盐选、文章、想法、关注[赞同/关注了XX]等)、屏蔽低赞/低评回答、屏蔽用户、屏蔽关键词、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回到顶部(右键两侧)、区分问题文章、移除高亮链接、净化搜索热门、净化标题消息、展开问题描述、显示问题作者、默认高清原图(无水印)、置顶显示时间、完整问题时间、直达问题按钮、默认站外直链...
@@ -1583,7 +1583,7 @@ function blockHotOther() {
15831583

15841584
// 针对首页互相切换(知乎这里切换是动态加载的),为了避免功能交叉混乱,用户切换后刷新一下网页
15851585
function switchHome() {
1586-
document.querySelectorAll('a[aria-controls=Topstory-follow]:not(.is-active), a[aria-controls=Topstory-hot]:not(.is-active), a[aria-controls=Topstory-column-square]:not(.is-active)').forEach((a)=>{
1586+
document.querySelectorAll('a[aria-controls=Topstory-follow], a[aria-controls=Topstory-hot], a[aria-controls=Topstory-column-square]').forEach((a)=>{
15871587
a.outerHTML = a.outerHTML;
15881588
})
15891589
}
@@ -1600,7 +1600,12 @@ function switchHome() {
16001600
blockYanXuan(); // 屏蔽盐选内容
16011601
}, 300);
16021602
} else if (location.pathname == '/') { // 首页 - 推荐
1603-
location.reload(); // 针对首页互相切换(知乎这里切换是动态加载的),为了避免功能交叉混乱,用户切换后刷新一下网页
1603+
// 针对首页互相切换(知乎这里切换是动态加载的),为了避免功能交叉混乱,用户切换后刷新一下网页
1604+
if (GM_info.scriptHandler === 'Violentmonkey' || (GM_info.scriptHandler === 'Tampermonkey' && parseFloat(GM_info.version.slice(0,4)) >= 4.18)) {
1605+
setTimeout(()=>{location.reload();},200);
1606+
} else {
1607+
location.reload();
1608+
}
16041609
}
16051610
})
16061611

@@ -1609,7 +1614,7 @@ function switchHome() {
16091614
// Violentmonkey 比 Tampermonkey 加载更早,会导致一些元素还没加载,因此需要延迟一会儿
16101615
// Tampermonkey 4.18.0 版本可能需要延迟一会执行
16111616
if (GM_info.scriptHandler === 'Violentmonkey' || (GM_info.scriptHandler === 'Tampermonkey' && parseFloat(GM_info.version.slice(0,4)) >= 4.18)) {
1612-
setTimeout(start, 300);
1617+
setTimeout(start, 200);
16131618
} else {
16141619
start();
16151620
}

0 commit comments

Comments
 (0)