|
3 | 3 | // @name:zh-CN 知乎增强 |
4 | 4 | // @name:zh-TW 知乎增強 |
5 | 5 | // @name:ru Улучшение Zhihu |
6 | | -// @version 2.3.13 |
| 6 | +// @version 2.3.14 |
7 | 7 | // @author X.I.U |
8 | 8 | // @description A more personalized Zhihu experience~ |
9 | 9 | // @description:zh-CN 屏蔽指定类别(视频、盐选、文章、想法、关注[赞同了XX/关注了XX]等等)、屏蔽用户、屏蔽关键词、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回到顶部(右键两侧)、区分问题文章、移除高亮链接、净化搜索热门、净化标题消息、展开问题描述、显示问题作者、默认高清原图(无水印)、置顶显示时间、完整问题时间、直达问题按钮、默认站外直链... |
@@ -1115,6 +1115,8 @@ function addTypeTips() { |
1115 | 1115 | let style = `font-weight: bold;font-size: 13px;padding: 1px 4px 0;border-radius: 2px;display: inline-block;vertical-align: top;margin: ${(location.pathname === '/search') ? '2' : '4'}px 4px 0 0;` |
1116 | 1116 | document.body.appendChild(document.createElement('style')).textContent = `/* 区分问题文章 */ |
1117 | 1117 | .AnswerItem .ContentItem-title a:not(.zhihu_e_toQuestion)::before {content:'问题';color: #f68b83;background-color: #f68b8333;${style}} |
| 1118 | +/* 针对的是部分搜索词下搜索页开头的 "最新讨论" 之类的非常规元素 */ |
| 1119 | +.HotLanding-contentItem .ContentItem[data-za-detail-view-path-module=Content] .ContentItem-title a:not(.zhihu_e_toQuestion)::before {content:'问题';color: #f68b83;background-color: #f68b8333;${style}} |
1118 | 1120 | .TopstoryQuestionAskItem .ContentItem-title a:not(.zhihu_e_toQuestion)::before {content:'问题';color: #ff5a4e;background-color: #ff5a4e33;${style}} |
1119 | 1121 | .ZVideoItem .ContentItem-title a::before, .ZvideoItem .ContentItem-title a::before {content:'视频';color: #00BCD4;background-color: #00BCD433;${style}} |
1120 | 1122 | .PinItem .ContentItem-title a::before {content:'想法';color: #4CAF50;background-color: #4CAF5033;${style}} |
@@ -1157,7 +1159,9 @@ function addToQuestion() { |
1157 | 1159 | titleA.innerHTML = titleA.innerHTML.replace('?', "?") |
1158 | 1160 | } |
1159 | 1161 | if (/answer\/\d+/.test(titleA.href)) { // 如果是指向回答的问题(而非指向纯问题的链接) |
1160 | | - titleA.insertAdjacentHTML('afterend', `<a class="zhihu_e_toQuestion VoteButton" href="${titleA.parentElement.parentElement.querySelector('meta[itemprop="url"]').content}" target="_blank">直达问题</a>`); |
| 1162 | + const titleA_meta = titleA.parentElement.parentElement.querySelector('meta[itemprop="url"]'); // 获取该问题页地址 |
| 1163 | + if (!titleA_meta) return // 判断元素是否存在(针对的是部分搜索词下搜索页开头的 "最新讨论" 之类的非常规元素) |
| 1164 | + titleA.insertAdjacentHTML('afterend', `<a class="zhihu_e_toQuestion VoteButton" href="${titleA_meta.content}" target="_blank">直达问题</a>`); |
1161 | 1165 | } |
1162 | 1166 | } |
1163 | 1167 |
|
|
0 commit comments