修复 [区别问题文章] 功能误识别带蓝标/黄标的用户名问题(仅搜索页)

This commit is contained in:
xiu2
2021-04-25 10:56:35 +08:00
parent 0d2c3cdd8c
commit cd49cd4ce1
+3 -1
View File
@@ -1,6 +1,6 @@
// ==UserScript==
// @name 知乎增强
// @version 1.3.5
// @version 1.3.6
// @author X.I.U
// @description 移除登录弹窗、一键收起回答、收起当前回答/评论(点击两侧空白处)、快捷回到顶部(右键两侧空白处)、置顶显示时间、显示问题时间、区分问题文章、默认高清原图、默认站外直链
// @match *://www.zhihu.com/*
@@ -204,11 +204,13 @@ function addTypeTips() {
if (patt_zhuanlan.test(postList[num].href)) { // 如果是文章
postList[num].innerHTML = `<small class="zhihu_e_tips" style="color: #ffffff;font-weight: normal;font-size: 12px;padding: 0 3px;border-radius: 2px;background-color: #2196F3;display: inline-block;height: 18px;">文章</small> ` + postList[num].innerHTML
} else if (patt_question.test(postList[num].href)) { // 如果是问题
if (!postList[num].getAttribute('data-tooltip')) { // 排除用户名后面的蓝标、黄标等链接
if (patt_question_answer.test(postList[num].href)) { // 如果是指向回答的问题(而非指向纯问题的链接)
postList[num].innerHTML = `<small class="zhihu_e_tips" style="color: #ffffff;font-weight: normal;font-size: 12px;padding: 0 3px;border-radius: 2px;background-color: #f68b83;display: inline-block;height: 18px;">问题</small> ` + postList[num].innerHTML
} else {
postList[num].innerHTML = `<small class="zhihu_e_tips" style="color: #ffffff;font-weight: normal;font-size: 12px;padding: 0 3px;border-radius: 2px;background-color: #ff5a4e;display: inline-block;height: 18px;">问题</small> ` + postList[num].innerHTML
}
}
} else if (patt_video.test(postList[num].href)) { // 如果是视频
postList[num].innerHTML = `<small class="zhihu_e_tips" style="color: #ffffff;font-weight: normal;font-size: 12px;padding: 0 3px;border-radius: 2px;background-color: #00BCD4;display: inline-block;height: 18px;">视频</small> ` + postList[num].innerHTML
}