forked from sngxpro/AutoSyncScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzhihu.js
More file actions
63 lines (52 loc) · 1.87 KB
/
zhihu.js
File metadata and controls
63 lines (52 loc) · 1.87 KB
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
/*
[rewrite_local]
# 知乎(部分替换为手机百度 Quark 的 User-Agent)
^https:\/\/www\.zhihu\.com\/ url request-header (\r\n)User-Agent:.+(\r\n) request-header $1User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1 Quark/604.1 T7/10.7 SearchCraft/2.7.7 (Baidu; P1 9.0.0)$2
# 知乎网页直接看
^https://www\.zhihu\.com/question/ url script-response-body https://raw.githubusercontent.com/id77/QuantumultX/master/Script/zhihu.js
^https://zhuanlan\.zhihu\.com/p/ url script-response-body https://raw.githubusercontent.com/id77/QuantumultX/master/Script/zhihu.js
# 知乎网页去广告&推荐列表
https://www\.zhihu\.com/api/v4/questions/\d+/related-readings url reject-200
https://www\.zhihu\.com/api/v4/answers/\d+/related-readings url reject-200
https://www\.zhihu\.com/api/v4/hot_recommendation url reject-200
https://www\.zhihu\.com/commercial_api/banners_v3/mobile_banner url reject-200
https://zhuanlan\.zhihu\.com/api/articles/\d+/recommendation url reject-200
[mitm]
hostname = www.zhihu.com, zhuanlan.zhihu.com
*/
let html = $response.body;
let nonce = html.match(/nonce="[\w\-]*"/g)[1];
html = html.replace('apple-itunes-app', '');
html =
html.replace(/(<\/html>)/, '') +
`
<style ${nonce}>
.OpenInAppButton.is-shown {
-webkit-transform:translate(-50%,50px) !important;
transform: translate(-50%,50px) !important;
}
.CommentsForOia button {
display: none;
}
</style>
<script ${nonce}>
setTimeout(
() => {
document.querySelector(".MobileModal-wrapper").remove()
}
,
100
)
setTimeout(
() => {
document.querySelector("body").style.overflow = "auto"
document.querySelector(".Question-main").removeAttribute("class")
// document.querySelectorAll(".ContentItem-expandButton").forEach(item => item.click())
}
,
600
)
</script>
</html>
`;
$done({ body: html });