|
3 | 3 | // @name:zh-CN 知乎增强 |
4 | 4 | // @name:zh-TW 知乎增強 |
5 | 5 | // @name:en Zhihu enhancement |
6 | | -// @version 2.3.8 |
| 6 | +// @version 2.3.9 |
7 | 7 | // @author X.I.U |
8 | 8 | // @description 屏蔽指定类别(视频、盐选、文章、想法、关注[赞同了XX/关注了XX]等等)、屏蔽用户、屏蔽关键词、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回到顶部(右键两侧)、区分问题文章、移除高亮链接、净化搜索热门、净化标题消息、展开问题描述、显示问题作者、默认高清原图(无水印)、置顶显示时间、完整问题时间、直达问题按钮、默认站外直链... |
9 | 9 | // @description:zh-TW 屏蔽指定類別(視頻、鹽選、文章、想法、關注[贊同了XX/關注了XX]等等)、屏蔽用戶、屏蔽關鍵詞、默認收起回答、快捷收起回答/評論、快捷回到頂部、區分問題文章、移除高亮鏈接、默認高清原圖(無水印)、默認站外直鏈... |
@@ -657,7 +657,7 @@ function blockUsers(type) { |
657 | 657 | for (const target of mutation.addedNodes) { |
658 | 658 | if (target.nodeType != 1) return |
659 | 659 | //console.log(target, target.className) |
660 | | - if (target.className && (target.className.indexOf('css-') == 0 || target.style == 'opacity: 1;')) { |
| 660 | + if (target.tagName == 'DIV' && target.className && (target.className.indexOf('css-') == 0 || target.style == 'opacity: 1;')) { |
661 | 661 | const item = target.querySelector('.MemberButtonGroup.ProfileButtonGroup.HoverCard-buttons'), |
662 | 662 | item1 = target.querySelector('img.Avatar+div span.UserLink>a.UserLink-link[data-za-detail-view-element_name=User]'); |
663 | 663 | if (item1) { |
@@ -1178,40 +1178,6 @@ function questionRichTextMore() { |
1178 | 1178 | } |
1179 | 1179 |
|
1180 | 1180 |
|
1181 | | -// 知乎免登录 |
1182 | | -function removeLogin() { |
1183 | | - const removeLoginModal = (mutationsList, observer) => { |
1184 | | - for (const mutation of mutationsList) { |
1185 | | - for (const target of mutation.addedNodes) { |
1186 | | - if (target.nodeType != 1) return |
1187 | | - if (target.querySelector('.signFlowModal')) { |
1188 | | - let button = target.querySelector('.Button.Modal-closeButton.Button--plain'); |
1189 | | - if (button) button.click(); |
1190 | | - } else if (getXpath('//button[text()="立即登录/注册"]',target)) { |
1191 | | - target.remove(); |
1192 | | - } |
1193 | | - } |
1194 | | - } |
1195 | | - }; |
1196 | | - |
1197 | | - // 未登录时才会监听并移除登录弹窗 |
1198 | | - if(location.hostname === 'zhuanlan.zhihu.com') { // 如果是文章页 |
1199 | | - if (!document.querySelector('.ColumnPageHeader-profile>.AppHeader-menu')) { // 未登录 |
1200 | | - const observer = new MutationObserver(removeLoginModal); |
1201 | | - observer.observe(document, { childList: true, subtree: true }); |
1202 | | - if (getXpath('//button[text()="登录/注册"]')) getXpath('//button[text()="登录/注册"]').outerHTML = '<a class="Button AppHeader-login Button--blue" href="https://www.zhihu.com/signin" target="_blank">登录/注册</a>'; // [登录] 按钮跳转至登录页面 |
1203 | | - } |
1204 | | - } else { // 不是文章页 |
1205 | | - if (!document.querySelector('.AppHeader-profile>.AppHeader-menu')) { // 未登录 |
1206 | | - const observer = new MutationObserver(removeLoginModal); |
1207 | | - observer.observe(document, { childList: true, subtree: true }); |
1208 | | - document.lastElementChild.appendChild(document.createElement('style')).textContent = '.Question-mainColumnLogin, button.AppHeader-login {display: none !important;}'; // 屏蔽问题页中间的登录提示 |
1209 | | - if (getXpath('//button[text()="登录/注册"]')) getXpath('//button[text()="登录/注册"]').outerHTML = '<a class="Button AppHeader-login Button--blue" href="https://www.zhihu.com/signin" target="_blank">登录/注册</a>'; // [登录] 按钮跳转至登录页面 |
1210 | | - } |
1211 | | - } |
1212 | | -} |
1213 | | - |
1214 | | - |
1215 | 1181 | // 净化标题消息 |
1216 | 1182 | function cleanTitles() { |
1217 | 1183 | if (!menu_value('menu_cleanTitles')) return |
@@ -1518,7 +1484,6 @@ function blockHotOther() { |
1518 | 1484 | } |
1519 | 1485 | }) |
1520 | 1486 |
|
1521 | | - removeLogin(); // 移除登录弹窗,Violentmonkey 不能延迟执行这个 |
1522 | 1487 | cleanTitles(); // 净化标题消息,不能延迟执行 |
1523 | 1488 | // Violentmonkey 比 Tampermonkey 加载更早,会导致一些元素还没加载,因此需要延迟一会儿 |
1524 | 1489 | // Tampermonkey 4.18.0 版本可能需要延迟一会执行 |
|
0 commit comments