11// ==UserScript==
22// @name 知乎增强
3- // @version 1.6.3
3+ // @version 1.6.4
44// @author X.I.U
55// @description 移除登录弹窗、默认收起回答、一键收起回答、收起当前回答/评论(点击两侧空白处)、快捷回到顶部(右键两侧空白处)、屏蔽用户 (发布的内容)、屏蔽关键词(标题/评论)、屏蔽盐选内容、展开问题描述、置顶显示时间、显示问题时间、区分问题文章、直达问题按钮、默认高清原图、默认站外直链
66// @match *://www.zhihu.com/*
@@ -927,13 +927,12 @@ function addTypeTips() {
927927function addToQuestion ( ) {
928928 if ( ! menu_value ( 'menu_toQuestion' ) ) return
929929
930- // 添加按钮样式
931- 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;}` ;
932-
933- // 一开始加载的信息流
930+ // 一开始加载的信息流 + 添加按钮样式
934931 if ( location . pathname === '/search' ) {
932+ 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;}` ;
935933 addSetInterval_ ( 'h2.ContentItem-title a:not(.zhihu_e_tips)' ) ;
936934 } else {
935+ 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;}` ;
937936 document . querySelectorAll ( 'h2.ContentItem-title a:not(.zhihu_e_tips)' ) . forEach ( function ( item ) { addTypeTips_ ( item ) ; } )
938937 }
939938
@@ -955,8 +954,11 @@ function addToQuestion() {
955954 function addTypeTips_ ( titleA ) {
956955 if ( ! titleA ) return // 判断是否为真
957956 if ( titleA . parentElement . querySelector ( 'a.zhihu_e_toQuestion' ) ) return // 判断是否已添加
957+ if ( titleA . textContent . indexOf ( '?' ) != - 1 ) { // 把问题末尾英文问好 [?] 的替换为中文问好 [?],这样按钮与标题之间的间距就刚刚好~
958+ titleA . innerHTML = titleA . innerHTML . replace ( '?' , "?" )
959+ }
958960 if ( / a n s w e r \/ \d + / . test ( titleA . href ) ) { // 如果是指向回答的问题(而非指向纯问题的链接)
959- titleA . insertAdjacentHTML ( 'afterend' , `<a class="zhihu_e_toQuestion VoteButton" href="${ titleA . parentElement . querySelector ( 'meta[itemprop="url"]' ) . content } " target="_blank"><span style="display: inline-flex; align-items: center;"><svg class="Zi Zi--TriangleUp VoteButton-TriangleUp zhihu_e_toQuestion" fill="currentColor" viewBox="0 0 24 24" width="10" height="10"><path d="M2 18.242c0-.326.088-.532.237-.896l7.98-13.203C10.572 3.57 11.086 3 12 3c.915 0 1.429.571 1.784 1.143l7.98 13.203c.15.364.236.57.236.896 0 1.386-.875 1.9-1.955 1.9H3.955c-1.08 0-1.955-.517-1.955-1.9z" fill-rule="evenodd"></path></svg></span> 直达问题</a>` ) ;
961+ titleA . insertAdjacentHTML ( 'afterend' , `<a class="zhihu_e_toQuestion VoteButton" href="${ titleA . parentElement . querySelector ( 'meta[itemprop="url"]' ) . content } " target="_blank">直达问题</a>` ) ;
960962 }
961963 }
962964
0 commit comments