File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515| 脚本名称 | 脚本功能 | 安装 | 备用 |
1616| :---- | :---- | :----: | :----: |
1717| ** 知乎增强** | 宽屏显示 | ** [ 「安装」] ( https://greasyfork.org/scripts/412212 ) ** | ** [ 「安装」] ( https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/ZhihuEnhanced-Widescreen.user.js ) ** |
18+ | ** 知乎增强** | 区分问题和文章 | ** [ 「安装」] ( https://greasyfork.org/scripts/414027 ) ** | ** [ 「安装」] ( https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/ZhihuEnhanced-TypeTip.user.js ) ** |
1819| ** 知乎增强** | 一键收起长篇回答 | ** [ 「安装」] ( https://greasyfork.org/scripts/412205 ) ** | ** [ 「安装」] ( https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/ZhihuEnhanced-CollapsedAnswer.user.js ) ** |
1920| ** 知乎增强** | 默认显示高清原图 | ** [ 「安装」] ( https://greasyfork.org/scripts/412217 ) ** | ** [ 「安装」] ( https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/ZhihuEnhanced-HD-Pictures.user.js ) ** |
2021| ** 知乎增强** | 置顶显示发布时间/编辑时间 | ** [ 「安装」] ( https://greasyfork.org/scripts/412216 ) ** | ** [ 「安装」] ( https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/ZhihuEnhanced-Time.user.js ) ** |
Original file line number Diff line number Diff line change 1+ // ==UserScript==
2+ // @name 知乎增强 - 区分问题和文章
3+ // @version 1.0.0
4+ // @author X.I.U
5+ // @description 首页和搜索页列表中的标题开头添加问题、文章提示
6+ // @match *://www.zhihu.com/
7+ // @match *://www.zhihu.com/search*
8+ // @icon https://static.zhihu.com/static/favicon.ico
9+ // @license GPL-3.0 License
10+ // @run -at document-end
11+ // @namespace https://greasyfork.org/scripts/414027
12+ // ==/UserScript==
13+
14+ ( function ( ) {
15+ var postNum ;
16+
17+ setInterval ( aaaaa , 1000 ) ;
18+ //setTimeout(aaaaa, 1000);
19+
20+ function aaaaa ( ) {
21+ // URL 匹配正则表达式
22+ var patt_zhuanlan = / z h u a n l a n .z h i h u .c o m / ,
23+ patt_question = / q u e s t i o n \/ \d + / ,
24+ patt_tip = / z h i h u _ e _ t i p s /
25+ var postList = document . querySelectorAll ( 'a[data-za-detail-view-id]' ) ;
26+ postNum = document . querySelectorAll ( 'small.zhihu_e_tips' ) ;
27+ //console.log(`${postList.length} ${postNum.length}`);
28+ if ( postList . length > postNum . length ) {
29+ for ( var num = postNum . length ; num < postList . length ; num ++ ) {
30+ if ( ! patt_tip . test ( postList [ num ] . innerHTML ) ) { // 判断是否已添加
31+ if ( patt_zhuanlan . test ( postList [ num ] . href ) ) { // 如果是文章
32+ 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: #0084ff;display: inline-block;height: 18px;">文章</small> ` + postList [ num ] . innerHTML
33+ } else if ( patt_question . test ( postList [ num ] . href ) ) { // 如果是问题
34+ 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: #fd7672;display: inline-block;height: 18px;">问题</small> ` + postList [ num ] . innerHTML
35+ }
36+ //postNum += 1;
37+ }
38+ }
39+ }
40+ }
41+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments