From e1a70ffbc32f4a6a41d35ae65ec8d9fa09687a63 Mon Sep 17 00:00:00 2001 From: xiu2 <54703944+XIU2@users.noreply.github.com> Date: Mon, 16 Aug 2021 16:26:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20[=E7=9B=B4=E8=BE=BE?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E6=8C=89=E9=92=AE]=20=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E5=8F=8A=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zhihu-Enhanced.user.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Zhihu-Enhanced.user.js b/Zhihu-Enhanced.user.js index 931fb89..143e91e 100644 --- a/Zhihu-Enhanced.user.js +++ b/Zhihu-Enhanced.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 知乎增强 -// @version 1.6.3 +// @version 1.6.4 // @author X.I.U // @description 移除登录弹窗、默认收起回答、一键收起回答、收起当前回答/评论(点击两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽用户 (发布的内容)、屏蔽关键词(标题/评论)、屏蔽盐选内容、展开问题描述、置顶显示时间、显示问题时间、区分问题文章、直达问题按钮、默认高清原图、默认站外直链 // @match *://www.zhihu.com/* @@ -927,13 +927,12 @@ function addTypeTips() { function addToQuestion() { if (!menu_value('menu_toQuestion')) return - // 添加按钮样式 - document.lastChild.appendChild(document.createElement('style')).textContent = `svg.zhihu_e_toQuestion {-webkit-transform: rotate(270deg);transform: rotate(270deg);} a.zhihu_e_toQuestion {font-size: 14px;font-weight: normal;padding: 3px 5px;margin-left: 3px;border-radius: 3px;}`; - - // 一开始加载的信息流 + // 一开始加载的信息流 + 添加按钮样式 if (location.pathname === '/search') { + document.lastChild.appendChild(document.createElement('style')).textContent = `a.zhihu_e_toQuestion {font-size: 14px !important;font-weight: normal !important;padding: 0 6px 2px !important;border-radius: 3px !important;display: inline-block !important;vertical-align: top !important;height: 23px !important;}`; addSetInterval_('h2.ContentItem-title a:not(.zhihu_e_tips)'); } else { + document.lastChild.appendChild(document.createElement('style')).textContent = `a.zhihu_e_toQuestion {font-size: 14px !important;font-weight: normal !important;padding: 2px 6px !important;border-radius: 3px !important;display: inline-block !important;vertical-align: top !important;}`; document.querySelectorAll('h2.ContentItem-title a:not(.zhihu_e_tips)').forEach(function(item){addTypeTips_(item);}) } @@ -955,8 +954,11 @@ function addToQuestion() { function addTypeTips_(titleA) { if (!titleA) return // 判断是否为真 if (titleA.parentElement.querySelector('a.zhihu_e_toQuestion')) return // 判断是否已添加 + if (titleA.textContent.indexOf('?') != -1) { // 把问题末尾英文问好 [?] 的替换为中文问好 [?],这样按钮与标题之间的间距就刚刚好~ + titleA.innerHTML = titleA.innerHTML.replace('?', "?") + } if (/answer\/\d+/.test(titleA.href)) { // 如果是指向回答的问题(而非指向纯问题的链接) - titleA.insertAdjacentHTML('afterend', `直达问题`); + titleA.insertAdjacentHTML('afterend', `直达问题`); } }