Skip to content

Commit 284182a

Browse files
committed
修复 上个版本更新导致无法打开评论的问题
1 parent 28c1d3a commit 284182a

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

Zhihu-Enhanced.user.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 知乎增强
3-
// @version 1.3.9
3+
// @version 1.4.0
44
// @author X.I.U
55
// @description 移除登录弹窗、一键收起回答、收起当前回答/评论(点击两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽指定用户、屏蔽盐选内容、置顶显示时间、显示问题时间、区分问题文章、默认高清原图、默认站外直链
66
// @match *://www.zhihu.com/*
@@ -284,7 +284,7 @@ function blockUsers(type) {
284284
let item = e.target.getElementsByClassName('List-item')[0];
285285
let listName = item.querySelector('.RichText.ztext.CopyrightRichText-richText b') // 用户名所在元素
286286
if (listName) {
287-
blockUsersList.forEach(function(item1){ // 遍历用户黑名单
287+
menu_value('menu_customBlockUsers').forEach(function(item1){ // 遍历用户黑名单
288288
if (item1 === listName.innerText) { // 找到就删除该搜索结果
289289
console.log(listName.innerText);
290290
item.parentNode.remove();
@@ -359,8 +359,10 @@ function addEventListener_DOMNodeInserted() {
359359
// 知乎免登录,修改自:https://greasyfork.org/zh-CN/scripts/417126
360360
let removeLoginModal = e => {
361361
if (e.target.innerHTML && e.target.getElementsByClassName('Modal-wrapper').length > 0) {
362-
let button = e.target.getElementsByClassName('Button Modal-closeButton Button--plain')[0];
363-
if (button)button.click();
362+
if (e.target.getElementsByClassName('Modal-wrapper')[0].querySelector('.signFlowModal')){
363+
let button = e.target.getElementsByClassName('Button Modal-closeButton Button--plain')[0];
364+
if (button)button.click();
365+
}
364366
}
365367
}
366368

@@ -378,13 +380,19 @@ function addEventListener_DOMNodeInserted() {
378380
}
379381
}
380382

381-
if (document.querySelector('button.AppHeader-login')){ // 未登录时才会监听并移除登录弹窗
382-
document.addEventListener('DOMNodeInserted', removeLoginModal);
383-
document.querySelector('button.AppHeader-login').onclick=function(){location.href='https://www.zhihu.com/signin';} // [登录] 按钮跳转至登录页面
384-
document.querySelector('.AppHeader-profile button.Button--primary').onclick=function(){location.href='https://www.zhihu.com/signin';} // [加入知乎] 按钮跳转至注册页面(实际上是同一个页面)
385-
} else if(window.location.href.indexOf("zhuanlan") > -1){
386-
document.addEventListener('DOMNodeInserted', removeLoginModal);
383+
// 未登录时才会监听并移除登录弹窗
384+
if(window.location.href.indexOf("zhuanlan") > -1) { // 如果是文章页
385+
if (!document.querySelector('button.ColumnPageHeader-MenuToggler')) { // 判断不存在,则已登录
386+
document.addEventListener('DOMNodeInserted', removeLoginModal);
387+
}
388+
} else { // 不是文章页
389+
if (document.querySelector('button.AppHeader-login')) { // 如果存在,则未登录
390+
document.addEventListener('DOMNodeInserted', removeLoginModal);
391+
document.querySelector('button.AppHeader-login').onclick=function(){location.href='https://www.zhihu.com/signin';} // [登录] 按钮跳转至登录页面
392+
document.querySelector('.AppHeader-profile button.Button--primary').onclick=function(){location.href='https://www.zhihu.com/signin';} // [加入知乎] 按钮跳转至注册页面(实际上是同一个页面)
393+
}
387394
}
395+
388396
document.addEventListener('DOMNodeInserted', collapseNowComment); // 收起当前评论(监听点击事件,点击网页两侧空白处)
389397
}
390398

0 commit comments

Comments
 (0)