forked from billiumgates/tampermonkeys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
removeBullshitPrototyped.js
154 lines (132 loc) · 3.53 KB
/
removeBullshitPrototyped.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
"use strict";
class PageAction {
constructor(actionName) {
if (this.constructor === PageAction) {
throw new Error("Cannot instantiate Abstract Class");
}
this.name = actionName;
this.complete = false;
}
getName() {
return this.name;
}
setName(newName) {
this.name = newName;
}
isComplete() {
return this.complete;
}
setIsComplete(completed) {
this.complete = completed;
}
doAction() {
throw new Error("This method is abstract and must be implemented in concrete class.");
}
}
class RemovablePageActions extends PageAction {
constructor(classesToRemove) {
super(classesToRemove);
}
doAction() {
if (Array.isArray(this.getName()) === true) {
for (let item of this.getName()) {
this.remove(item);
}
} else {
this.remove(this.getName());
}
}
remove(selectorToRemove) {
document.querySelector(selectorToRemove).remove();
}
}
class PopupClosePageAction extends PageAction {
constructor() {
super("Close Popup");
}
doAction() {
document.querySelector(".overlay-wrapper").querySelector("button").click();
}
}
class RemoveScorePaddingPageAction extends PageAction {
constructor() {
super("Remove Score Padding");
}
doAction() {
document.querySelector(".show_live_scores").style.padding = 0;
}
}
class AdjustHeaderPageAction extends PageAction {
constructor() {
super("Adjust Header");
}
doAction() {
document.querySelector(".stream-wrapper").querySelector("header").style.height = 0;
var gameSelector = document.querySelector(".stream-wrapper").querySelector("header").querySelector(".selector");
gameSelector.style.position = "absolute";
gameSelector.style.top = "96%";
gameSelector.style.left = "50%";
}
}
class RemoveRouterWrapperAndFooterPageAction extends RemovablePageActions {
constructor() {
super(".router-wrapper");
}
doAction() {
//Remove the footer at the bottom of the page
document.querySelector(this.getName()).nextElementSibling.remove();
super.doAction();
}
}
var retryTimeout = 500;
var retryCount = 0;
var maxRetries = 40;
var removableClasses = [
".turbo",
".cast",
".download-button",
".chat-wrapper",
".top-nav",
".prediction-wrapper",
".router-links",
];
let actions = [
new PopupClosePageAction(),
new RemoveScorePaddingPageAction(),
new AdjustHeaderPageAction(),
new RemovablePageActions(removableClasses),
new RemoveRouterWrapperAndFooterPageAction(),
];
document.onload = setTimeout(() => {
console.debug("Removing bullshit");
removeBullshit();
console.debug("Bullshit removed");
}, retryTimeout);
function removeBullshit() {
var retry = false;
for (let action of actions) {
if (action.isComplete() === false) {
try {
action.doAction();
action.setIsComplete(true);
} catch (error) {
retry = true;
if (retryCount > maxRetries) {
console.error("Could not perform the action " + action.getName() + ":" + error);
retry = false;
} else {
console.debug(
"Could not perform the action " + action.getName() + ", will retry in " + retryTimeout + "ms",
);
}
}
}
}
if (retry === true) {
retryCount++;
setTimeout(() => {
console.debug("Retrying");
removeBullshit();
}, retryTimeout);
}
}