forked from billiumgates/tampermonkeys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
removeBullshitFunctionized.js
122 lines (109 loc) · 3.37 KB
/
removeBullshitFunctionized.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
"use strict";
class PageAction {
constructor(actionName, functionToExecute) {
this.name = actionName;
this.complete = false;
this.actionToExecute = functionToExecute;
}
getName() {
return this.name;
}
setName(newName) {
this.name = newName;
}
isComplete() {
return this.complete;
}
setIsComplete(completed) {
this.complete = completed;
}
doAction() {
this.actionToExecute();
}
}
let popupFunction = function actionOverlayWrapper() {
console.debug("Closing the popup");
document.querySelector(".overlay-wrapper").querySelector("button").click();
};
let scoresFunction = function actionScores() {
document.querySelector(".show_live_scores").style.padding = 0;
};
let headerFunction = function actionWrapper() {
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%";
};
var retryTimeout = 500;
var retryCount = 0;
var maxRetries = 40;
var removableClasses = [
".turbo",
".cast",
".download-button",
".chat-wrapper",
".top-nav",
".prediction-wrapper",
".router-links",
".router-wrapper",
];
var removableMap = new Map();
for (const c of removableClasses) {
removableMap.set(c, c);
}
let overlayAction = new PageAction(".overlay-wrapper", popupFunction);
let scoresAction = new PageAction(".show_live_scores", scoresFunction);
let wrapperAction = new PageAction(".stream-wrapper", headerFunction);
let actions = [overlayAction, scoresAction, wrapperAction];
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",
);
}
}
}
}
for (const [key, value] of removableMap.entries()) {
try {
if (key === ".router-wrapper") {
//Remove the footer at the bottom of the page
document.querySelector(key).nextElementSibling.remove();
}
document.querySelector(key).remove();
console.debug("Removed the item identified by selector: " + key);
} catch (error) {
retry = true;
if (retryCount > maxRetries) {
console.error("Could not remove find the " + key + " element: " + error);
retry = false;
} else {
console.debug("Could not remove find the " + key + " element, will retry in " + retryTimeout + "ms");
}
}
}
if (retry === true) {
retryCount++;
setTimeout(() => {
console.debug("Retrying");
removeBullshit();
}, retryTimeout);
}
}