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
/
main.js
105 lines (81 loc) · 2.04 KB
/
main.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
(() => {
'use strict';
const url = location.href;
if(url.startsWith('http://localhost/')) return;
var stage = 0;
var scrollScheduled = 1;
document.addEventListener('DOMContentLoaded', () => {
stage = 1;
scroll();
});
window.addEventListener('load', () => {
scroll();
});
window.addEventListener('scroll', () => {
scrollScheduled = 0;
});
main();
function main(){
scroll();
if(!document.body)
return setTimeout(main);
block();
function block(){
var e;
for(e of qsa('#searchResult:not(.ublock-safe)')){
if(qs(e, '.hide_your_ip_btn')) e.remove();
else e.classList.add('ublock-safe');
}
for(e of qsa('a[href="https://bitcoin.org"]')){
const e1 = e.parentNode;
if(e1){
const e2 = e1.parentNode;
if(e2 && e2 !== document.body && !qs(e2, '.download')) e2.remove();
else e1.remove();
}
}
if(stage === 0) return setTimeout(block);
}
}
function scroll(){
if(!scrollScheduled) return;
if(window.location.href.startsWith('https://www.youtube.com/')) return;
if(window.parent.frames.length === 0){
try{
window.scrollTo(0, 0);
document.documentElement.scrollTop = 0;
document.body.scrollTop = 0;
}catch{}
if(window.scrollY !== 0)
setTimeout(scroll);
}
}
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];
}
})();