MCPcopy Index your code
hub / github.com/XIU2/UserScript / switchHome

Function switchHome

Zhihu-Enhanced.user.js:1646–1648  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1644// 将关注/推荐/热榜/专栏的选项去掉默认的点击事件改成静态链接(针对首页互相切换(知乎这里切换是动态加载的),为了避免功能交叉混乱
1645// 针对所有页面
1646function switchHome() {
1647 document.querySelectorAll('header.AppHeader nav').forEach((a)=>{a.outerHTML = a.outerHTML;})
1648}
1649// 针对首页几个页面
1650function switchHomeRecommend() {
1651 document.querySelectorAll('header.AppHeader nav>a:not([target])[href="https://www.zhihu.com/"]').forEach((a)=>{a.addEventListener('click', function(e){e.preventDefault();document.cookie='tst=r; expires=Thu, 18 Dec 2099 12:00:00 GMT; domain=.zhihu.com; path=/';location.href=this.href;return false;})})

Callers 1

startFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected