-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtampermonkey.js
183 lines (170 loc) · 8.25 KB
/
tampermonkey.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// ==UserScript==
// @name 知乎浏览助手
// @namespace http://tampermonkey.net/
// @version 0.0.9
// @description 知乎浏览助手. 如果想报 bug, 可以通过知乎私信联系我, zhihu.com/people/kougazhang
// @author kgzhang
// @match https://www.zhihu.com/*
// @grant GM_addStyle
// @grant GM_log
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_openInTab
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_notification
// @run-at document-end
// ==/UserScript==
(function () {
'use strict';
/****************** Global ****************************************/
// Be largger the font;
GM_addStyle("body {font-size: 25px}");
// Hidden Topstory-hot
GM_addStyle('a[aria-controls="Topstory-hot"] { display: none !important; }');
// Hidden Topstory-zvideo
GM_addStyle('a[aria-controls="Topstory-zvideo"] { display: none !important; }');
// Hidden Topstory-recommend
// GM_addStyle('a[aria-controls="Topstory-recommend"] { display: none !important; }');
// Display 首页 only
GM_addStyle('ul[class~="AppHeader-Tabs"] :not(:first-child) { display: none !important; }')
// Hidden placeholder of search bar
GM_addStyle('::placeholder {color: transparent !important;}');
// rightButton 收起
GM_addStyle('.ContentItem-rightButton {color: red}');
// 返回顶部
GM_addStyle('.Zi--BackToTop {color: red}');
// hidden picture
// GM_addStyle("img {display: none !important; }");
/****************** Global ****************************************/
/****************** CornerButtons ****************************************/
// GM_addStyle('.CornerButtons { right: 400px; bottom: 50px}')
// GM_addStyle('.CornerAnimayedFlex { background: red; }')
/****************** CornerButtons ****************************************/
/***************** Follow page***********************/
// Remove RightSideBar
GM_addStyle("div[data-za-detail-view-path-module='RightSideBar'] { display: none !important; } ");
// Remove AD
GM_addStyle(".TopstoryItem--advertCard {display: none; }");
// Widen mainColumn
GM_addStyle(".Topstory-container { width: 1500px !important; } ");
GM_addStyle(".Topstory-mainColumn { width: 1500px !important; } ");
// Be lagger the font of question title
GM_addStyle('.ContentItem-title {font-size: x-large}');
/***************** Follow page***********************/
/***************** Recommand page***********************/
// hidden video
GM_addStyle(".TopstoryItem-isRecommend:has(.VideoAnswerPlayer-video) { display: none !important; } ");
GM_addStyle(".TopstoryItem-isRecommend:has(.ZVideoItem-video) { display: none !important; } ");
GM_addStyle(".TopstoryItem-isRecommend:has(.RichText-video) { display: none !important; } ");
// hidden article
GM_addStyle(".TopstoryItem-isRecommend:has(.CopyrightRichText-richTex) { display: none !important; } ");
// hidden having -LinkCard
GM_addStyle(".TopstoryItem-isRecommend:has(.RichText-LinkCardContainer) { display: none !important; } ");
// hidden for edu RichText-EduCardContainer
GM_addStyle(".TopstoryItem-isRecommend:has(.RichText-EduCardContainer) { display: none !important; } ");
// hidden zhuanlan
GM_addStyle('.TopstoryItem-isRecommend:has(div[data-za-extra-module*="Post"]) { display: none !important; }');
// hidden Ecommerce
GM_addStyle("TopstoryItem-isRecommend:has(.RichText-Ecommerce) {display: none !important; }");
GM_addStyle(".TopstoryItem-isRecommend:has(.ecommerce-ad-box) {display: none !important; }");
// color
// GM_addStyle(".TopstoryItem-isRecommend:nth-child(odd) {background: #f6f6f6}")
// GM_addStyle(".TopstoryItem-isRecommend:nth-child(even) {background: #dfe1e5}")
/***************** Recommand page***********************/
/****************** Question page *********************************/
// Widen mainColumn
GM_addStyle(".Question-main { width: 1500px !important; } ");
GM_addStyle(".Question-mainColumn { width: 1500px !important; } ");
// display & Make time at top
GM_addStyle('meta[itemprop="dateModified"] {display: block; height: 20px; padding: 10px}');
GM_addStyle('meta[itemprop="dateModified"]::after {content: "DateModified: " attr(content); color:#8590a6;}');
// hidden link,
// GM_addStyle(".AnswerItem:has(.RichText-LinkCardContainer) { display: none !important; } ");
// hidden video
GM_addStyle(".AnswerItem:has(.VideoCard-video-content) { display: none !important; } ");
GM_addStyle(".AnswerItem:has(.VideoAnswerPlayer) { display: none !important; } ");
// go back and refresh
document.querySelector('div[class="CornerButtons"]').addEventListener('click', (e)=>{
location.reload();
});
/****************** Question page *********************************/
/****************** Search page ***********************************************/
// Hidden right bar
GM_addStyle(".css-knqde {display: none !important;}");
// Widen main bar
GM_addStyle(".Search-container { width: 1500px !important; } ");
GM_addStyle(".SearchMain { width: 1500px !important; } ");
/****************** Search page ***********************************************/
/****************** Topic page ***********************************************/
// Widen main bar
GM_addStyle('div[data-za-detail-view-path-module="TopicItem"] { max-width: 1500px !important; } ');
/****************** Topic page ***********************************************/
/****************** Column page **********************************************************/
// GM_addStyle('main[role="main"]>div>div:last-child {width: 1500px}');
// GM_addStyle('main[role="main"]>div>div:last-child > div > div {width: 1500px}');
/****************** Column page **********************************************************/
/**************************** is-collapsed *************************************************/
// reload for MutationObserver
window.addEventListener('load', (e)=>{
console.log("load", e);
let btn=document.querySelector('a[class="QuestionMainAction ViewAll-QuestionMainAction"]');
btn.addEventListener('click', (e)=>{
e.stopPropagation();
let h = window.open(btn.href, "_self");
h.location.reload();
})
});
// close to is collapsed
try {
(new MutationObserver(mutations => {
if (!window.location.href.contains("zhihu.com/question")) {
console.log("href", window.location.href);
return
}
for(let mutation of mutations) {
if (mutation.addedNodes.length > 0) {
for (let node of mutation.addedNodes) {
if (node===null) {
continue;
}
node.querySelector('button[data-zop-retract-question="true"]').click();
}
}
}
})).observe(document.querySelector('div[role="list"]'), {
childList: true, // 观察直接子节点
subtree: true,
attributes: false,
characterData: false
});
} catch (e) {
console.log(e)
}
/**************************** is-collapsed *************************************************/
/******************* Free copy**********************************************/
let body = document.getElementsByTagName('body')[0];
body.addEventListener('copy', function (e) {
e.stopPropagation();
console.log("copy...");
}, false);
body.addEventListener('contextmenu', (e) => {
e.stopPropagation();
}, false);
body.addEventListener('select', (event) => {
event.stopPropagation();
}, false);
body.addEventListener('selectstart', (event) => {
event.stopPropagation();
}, false);
body.addEventListener('cut', (event) => {
event.stopPropagation();
}, false);
body.addEventListener('dragstart', (event) => {
event.stopPropagation();
}, false);
body.addEventListener('mousemove', (event) => {
event.stopPropagation();
}, false);
/******************* Free copy**********************************************/
})()