33// @name :zh-CN 知乎增强
44// @name :zh-TW 知乎增強
55// @name :ru Улучшение Zhihu
6- // @version 2.3.27
6+ // @version 2.3.28
77// @author X.I.U
88// @description A more personalized Zhihu experience~
99// @description :zh-CN 移除登录弹窗、屏蔽指定类别(视频、盐选、文章、想法、关注[赞同/关注了XX]等)、屏蔽低赞/低评回答、屏蔽用户、屏蔽关键词、默认收起回答、快捷收起回答/评论(左键两侧)、快捷回到顶部(右键两侧)、区分问题文章、移除高亮链接、净化搜索热门、净化标题消息、展开问题描述、显示问题作者、默认高清原图(无水印)、置顶显示时间、完整问题时间、直达问题按钮、默认站外直链...
@@ -36,7 +36,7 @@ var menu_ALL = [
3636 [ 'menu_collapsedAnswer' , '一键收起回答/评论' , '一键收起回答/评论' , true ] ,
3737 [ 'menu_collapsedNowAnswer' , '快捷收起回答/评论 (点击两侧空白处)' , '快捷收起回答/评论' , true ] ,
3838 [ 'menu_backToTop' , '快捷回到顶部 (右键两侧空白处)' , '快捷回到顶部' , true ] ,
39- [ 'menu_blockLowCount' , '屏蔽低赞低评' , '设置要屏蔽 低于多少赞同/评价 的回答(默认不需要留空即可)<br/>(例如设置 0 则无人赞同/评价的回答会被屏蔽 <br/>(例如设置 20 则赞同/评价数量低于 20 的回答会被屏蔽 <br/>(修改后,后续加载的回答会立即生效 ,但不影响当前网页已有内容' , '' ] ,
39+ [ 'menu_blockLowCount' , '屏蔽低赞低评' , '设置要屏蔽 低于多少赞同/评价 的回答/文章 (默认不需要留空即可)<br/>(例如设置 0 则无人赞同/评价的回答/文章会被屏蔽 <br/>(例如设置 20 则赞同/评价数量低于 20 的回答/文章会被屏蔽 <br/>(修改后,后续加载的回答/文章会立即生效 ,但不影响当前网页已有内容' , '' ] ,
4040 [ 'menu_blockLowUpvoteCount' , '最低赞同数 [首页]' , '最低赞同数(首页)' , '' ] ,
4141 [ 'menu_blockLowCommentCount' , '最低评价数 [首页]' , '最低评价数(首页)' , '' ] ,
4242 [ 'menu_blockLowUpvoteCountQuestion' , '最低赞同数 [问题页]' , '最低赞同数(问题页)' , '' ] ,
@@ -448,7 +448,7 @@ function isElementInViewport_(el) {
448448}
449449
450450
451- // 屏蔽低赞/低评回答
451+ // 屏蔽低赞/低评回答/文章
452452function blockLowCount ( type ) {
453453 switch ( type ) {
454454 case 'index' :
@@ -461,14 +461,16 @@ function blockLowCount(type) {
461461 blockLowCount_ ( '.List-item' , 'List-item' , 'menu_blockLowUpvoteCountQuestion' , 'menu_blockLowCommentCountQuestion' ) ;
462462 break ;
463463 }
464+ console . log ( type )
464465
465466
466467 function blockLowCount_ ( className1 , className2 , menuUpvote , menuComment ) {
467468 // 前几条因为是直接加载的,而不是动态插入网页的,所以需要单独判断
468469 function blockLowCount_now ( ) {
469470 document . querySelectorAll ( className1 ) . forEach ( function ( item1 ) {
470- blockLowCount_1 ( item1 , menuUpvote , 'meta[itemprop=upvoteCount]' ) ;
471- blockLowCount_1 ( item1 , menuComment , 'meta[itemprop=commentCount]' ) ;
471+ console . log ( item1 )
472+ blockLowCount_1 ( item1 , menuUpvote , 'upvote_num' ) ;
473+ blockLowCount_1 ( item1 , menuComment , 'comment_num' ) ;
472474 } )
473475 }
474476
@@ -483,8 +485,8 @@ function blockLowCount(type) {
483485 for ( const target of mutation . addedNodes ) {
484486 if ( target . nodeType != 1 ) return
485487 if ( target . className === className2 ) {
486- blockLowCount_1 ( target , menuUpvote , 'meta[itemprop=upvoteCount] ' ) ;
487- blockLowCount_1 ( target , menuComment , 'meta[itemprop=commentCount] ' ) ;
488+ blockLowCount_1 ( target , menuUpvote , 'upvote_num ' ) ;
489+ blockLowCount_1 ( target , menuComment , 'comment_num ' ) ;
488490 }
489491 }
490492 }
@@ -494,18 +496,17 @@ function blockLowCount(type) {
494496 }
495497
496498
497- function blockLowCount_1 ( item1 , menu , css ) {
499+ function blockLowCount_1 ( item , menu , type ) {
498500 if ( GM_getValue ( menu ) ) {
499- let item = item1 . querySelector ( css ) ;
500- //console.log(item)
501- if ( item && item . content && Number ( item . content ) < Number ( GM_getValue ( menu ) ) ) {
502- if ( menu . indexOf ( 'Upvote' ) !== - 1 ) {
503- console . log ( '已屏蔽低赞回答:' , item . content + '<' + GM_getValue ( menu ) , item1 , type ) ;
504- } else {
505- console . log ( '已屏蔽低评回答:' , item . content + '<' + GM_getValue ( menu ) , item1 , type ) ;
501+ let item_ContentItem = item . querySelector ( '.ContentItem' )
502+ if ( item_ContentItem && item_ContentItem . dataset . zaExtraModule ) {
503+ let item2 = JSON . parse ( item_ContentItem . dataset . zaExtraModule ) ;
504+ //console.log(item2)
505+ if ( item2 && item2 . card . content && Number ( item2 . card . content [ type ] ) < Number ( GM_getValue ( menu ) ) ) {
506+ console . log ( '已屏蔽' + ( type === 'upvote_num' ? '低赞' :'低评' ) + ( item_ContentItem . classList . contains ( 'AnswerItem' ) ? '回答' :'文章' ) + ':' , item2 . card . content [ type ] + '<' + GM_getValue ( menu ) , item ) ;
507+ item . hidden = true ;
508+ item . style . display = 'none' ;
506509 }
507- item1 . hidden = true ;
508- item1 . style . display = 'none' ;
509510 }
510511 }
511512 }
@@ -1684,7 +1685,7 @@ function switchHomeRecommend() {
16841685 collapsedNowAnswer ( '.Question-main' ) ; // 收起当前回答 + 快捷返回顶部
16851686 questionRichTextMore ( ) ; // 展开问题描述
16861687 if ( location . pathname . indexOf ( 'answer' ) == - 1 ) { // 问题页而不是回答页
1687- blockLowCount ( 'question' ) ; // 屏蔽低赞/低评回答
1688+ blockLowCount ( 'question' ) ; // 屏蔽低赞/低评回答/文章
16881689 } else { // 将回答页的的查看全部回答选项去掉默认的点击事件改成静态链接,为了避免功能交叉混乱
16891690 document . querySelectorAll ( 'div.Card.ViewAll>a' ) . forEach ( ( a ) => { a . outerHTML = a . outerHTML ; } )
16901691 }
@@ -1768,15 +1769,15 @@ function switchHomeRecommend() {
17681769 addTypeTips ( ) ; // 区分问题文章
17691770 addToQuestion ( ) ; // 直达问题按钮
17701771 if ( location . pathname == '/' ) { // 推荐
1771- blockLowCount ( 'index' ) ; // 屏蔽低赞/低评回答
1772+ blockLowCount ( 'index' ) ; // 屏蔽低赞/低评回答/文章
17721773 blockUsers ( 'index' ) ; // 屏蔽指定用户
17731774 blockKeywords ( 'index' ) ; // 屏蔽指定关键词
17741775 blockType ( ) ; // 屏蔽指定类别(视频/文章等)
17751776 } else if ( location . pathname == '/hot' ) { // 热榜
17761777 blockKeywords ( 'index' ) ; // 屏蔽指定关键词
17771778 blockHotOther ( ) ; // 屏蔽热榜杂项
17781779 } else if ( location . pathname == '/follow' ) { // 关注
1779- blockLowCount ( 'follow' ) ; // 屏蔽低赞/低评回答
1780+ blockLowCount ( 'follow' ) ; // 屏蔽低赞/低评回答/文章
17801781 blockUsers ( 'follow' ) ; // 屏蔽指定用户
17811782 blockKeywords ( 'follow' ) ; // 屏蔽指定关键词
17821783 blockType ( ) ; // 屏蔽指定类别(视频/文章等)
0 commit comments