forked from ipcjs/bilibili-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzhihu_mobile_fuck_style.user.js
159 lines (152 loc) · 3.72 KB
/
zhihu_mobile_fuck_style.user.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
// ==UserScript==
// @name Fuck ZhiHu Mobile Style
// @namespace https://github.com/ipcjs
// @version 2.1.2
// @description 日他娘的逼乎手机网页版 样式ver; 针对电脑版进行修改,适配手机屏幕;
// @author ipcjs
// @compatible chrome
// @compatible firefox
// @include https://www.zhihu.com/*
// @include https://zhuanlan.zhihu.com/*
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// @require https://greasyfork.org/scripts/373283-ipcjs-lib-js/code/ipcjslibjs.js?version=647820
// @grant GM_addStyle
// @grant GM.addStyle
// ==/UserScript==
GM.addStyle(`
/* Header */
.AppHeader {
min-width: inherit;
}
.AppHeader-inner {
width: 100%;
}
.SearchBar {
display: none;
}
.AppHeader-messages, .AppHeader-notifications {
margin-right: 16px;
}
.AppHeader-userInfo {
margin-right: 32px;
}
.AppHeader-navItem {
padding: 0 5px;
}
.AppHeader-nav {
margin-left: 16px;
margin-right: 16px;
}
.TopstoryPageHeader-main {
margin-left: 16px;
}
/* 通用列表 */
.Topstory-container, .Question-main, .Profile-main {
display: block;
width: 100%;
padding: 0px;
}
.Topstory-mainColumn, .Question-mainColumn, .Profile-mainColumn {
width: 100%;
}
.Question-sideColumn, .Profile-sideColumn {
width: 100%;
}
/* 回答页面的Header */
.QuestionHeader .QuestionHeader-content {
width: 100%;
display: block;
padding: 0px;
}
.QuestionHeader .QuestionHeader-main {
width: 100%;
}
.QuestionHeader .QuestionHeader-side {
width: 100%;
}
.QuestionHeader .NumberBoard {
margin: auto;
}
.QuestionHeader {
min-width: inherit;
}
.PageHeader .QuestionHeader-content {
width: 100%;
}
.PageHeader .QuestionHeader-main {
width: 100%;
padding: 0px;
}
.PageHeader .QuestionHeader-side {
display: none;
}
/* 个人主页的Header */
.ProfileHeader {
width: 100%;
padding: 0px;
}
/* 列表Item上的按钮 */
.ShareMenu {
display: none;
}
.ContentItem-action {
margin-left: 8px;
}
/* 专栏页面 */
.Post-NormalMain .Post-Header, .Post-NormalMain>div {
width: 100%;
}
.ColumnPageHeader-content {
width: 100%;
}
/* 弹窗 */
.Modal-closeButton {
position: static;
margin-left: auto;
margin-right: auto;
}
.Modal {
width: 100%;
}
`)
ipcjs.installInto(({ log, html, $ }) => {
log = GM_info.script.name.endsWith('.dev') ? log : () => { }
removeThankButton(document)
new MutationObserver((mutations, observer) => {
// log(mutations)
for (let m of mutations) {
for (let node of m.addedNodes) {
if (node.nodeType === Node.ELEMENT_NODE) {
removeThankButton(node)
}
}
}
}).observe(document.body, {
childList: true,
subtree: true
})
function removeThankButton(node) {
let count = 0
node.querySelectorAll('button.ContentItem-action')
.forEach(btn => {
let $text = btn.childNodes[1]
let group
if ($text && $text.nodeType === Node.TEXT_NODE) {
let text = $text.textContent
count++
if (text === '感谢' || text === '取消感谢') {
btn.style.display = 'none'
} else if (text === '举报' || text === '收藏') {
$text.textContent = ''
} else if ((group = text.match(/(\d+) 条评论/))) {
$text.textContent = `${group[1]}`
} else {
count--
}
}
})
if (count > 0) {
log(`modify: ${count}`)
}
}
})