This repository has been archived by the owner on Oct 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quora.js
108 lines (83 loc) · 2.25 KB
/
quora.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
(() => {
'use strict';
let stage = 0;
document.addEventListener('DOMContentLoaded', () => {
stage = 1;
});
main();
function main(){
block();
function block(){
for(const e of qsa('.q-box.qu-py--medium.qu-textAlign--center.qu-borderTop')){
e.remove();
}
for(const e of qsa('.q-box:not(.ublock-safe)')){
if(e.innerText.trim() === 'Related Questions'){
e.closest('div:not([class])').remove();
continue;
}
show(e);
}
for(const e of qsa('.spacing_log_answer_content:not(.ublock-safe)')){
const btn = [...qsa(e, '.q-click-wrapper')].find(a => a.innerText.trim() === 'Continue Reading');
if(btn) btn.click();
show(e);
}
for(const e of qsa('.pagedlist_item:not(.ublock-safe)')){
if(!e.closest('.answer_text_small')){
e.remove();
continue;
}
const str = e.innerText.trim();
if(str.length === 0) continue;
if(/promoted|(?:sponsored|ads?) +by /i.test(e.innerText)){
e.remove();
continue;
}
e.classList.add('ublock-safe');
}
for(const e of qsa('.UnifiedAnswerPagedList:not(.ublock-safe)')){
if(!e.closest('.answer_text_small')){
e.remove();
continue;
}
const str = e.innerText.trim();
if(str.length === 0) continue;
if(/\bad +by /i.test(e.innerText)){
e.remove();
continue;
}
e.classList.add('ublock-safe');
}
setTimeout(block, stage ? 1e3 : 0);
}
}
function show(e){
e.classList.add('ublock-safe');
}
function qs(a, b=null){
if(b === null){
b = a;
a = document;
}
return a.querySelector(b);
}
function qsa(a, b=null){
if(b === null){
b = a;
a = document;
}
return a.querySelectorAll(b);
}
function decode(str){
return str.split('').
map(a => a.charCodeAt(0) - 32).
map(a => 94 - a).
map(a => String.fromCharCode(32 + a)).
join('');
}
function log(...a){
console.log(...a);
return a[a.length - 1];
}
})();