forked from shenruisi/Stay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzhihu-content.js
81 lines (70 loc) · 2.59 KB
/
zhihu-content.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
function removeChoosePanel(){
let pannels = document.querySelectorAll('.ModalWrap');
for (var i = 0; i < pannels.length; i++){
let pannel = pannels[i];
let div = pannel.querySelector('.ModalExp-modalShow');
if (div){
let btns = div.querySelectorAll('.ModalWrap-itemBtn');
for (var i=0; i < btns.length; i++){
let button = btns[i];
if (button.innerText == "继续"){
button.click();
return COMPLETE;
}
}
}
}
return CONTINUE;
}
function removeAppJump(){
let app = document.querySelector('button.OpenInAppButton');
if (app){
var url = app.getAttribute("urlscheme");
app.remove();
return new App()
.id("zhihu")
.title(document.title)
.icon("https://is1-ssl.mzstatic.com/image/thumb/Purple125/v4/83/24/ca/8324ca44-40d5-87ed-4f8f-a47daec7dc34/AppIcon-0-0-1x_U007emarketing-0-0-0-6-0-0-sRGB-0-0-0-GLES2_U002c0-512MB-85-220-0-0.png/230x0w.png")
.url(url)
.data();
}
return CONTINUE;
}
function unfold(){
let btns = document.querySelectorAll('.ContentItem-expandButton');
for (var i = 0; i < btns.length; i++){
let btn = btns[i];
if (/展开阅读全文/.test(btn.innerText)){
let content = btn.parentNode;
if (content){
content.className = "RichContent RichContent--unescapable";
let contentinner = content.querySelector('.RichContent-inner');
if (contentinner){
contentinner.style.maxHeight = "none";
}
}
btn.remove();
let main = document.querySelector(".Question-main");
if (main){
main.onclick = function(event){
let target = event.target;
while(!/RichContent/.test(target.className) && target.tagName != "BODY"){
target = target.parentNode;
}
if (/RichContent/.test(target.className)){
event.preventDefault();
event.stopPropagation();
}
}
}
return COMPLETE;
}
}
return CONTINUE;
}
window.onload = function(){
let tasks = [removeChoosePanel,removeAppJump,unfold];
Inject.run(tasks,100,30,false).then((data) => {
browser.runtime.sendMessage({from:"content",operate:"saveAppList",data:data})
});
}