-
Notifications
You must be signed in to change notification settings - Fork 1
/
removeBullshit.js
126 lines (117 loc) · 3.72 KB
/
removeBullshit.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
"use strict";
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();
var popupClosed = false;
var paddingRemoved = false;
var headerHidden = false;
var gameSelectorMoved = false;
for (const c of removableClasses) {
removableMap.set(c, c);
}
document.onload = setTimeout(() => {
console.debug("Removing bullshit");
removeBullshit();
console.debug("Bullshit removed");
}, retryTimeout);
function removeBullshit() {
var retry = false;
if (popupClosed === false) {
try {
document.querySelector(".overlay-wrapper").querySelector("button").click();
popupClosed = true;
} catch (error) {
retry = true;
if (retryCount > maxRetries) {
console.error("Could not remove find the .overlay-wrapper to close the popup: " + error);
retry = false;
} else {
console.debug("Could not click the popup button, will retry in " + retryTimeout + "ms");
}
}
}
if (paddingRemoved === false) {
try {
document.querySelector(".show_live_scores").style.padding = 0;
paddingRemoved = true;
} catch (error) {
retry = true;
if (retryCount > maxRetries) {
console.error("Could not find the .show_live_scores to remove the padding: " + error);
retry = false;
} else {
console.debug("Could not remove padding, will retry in " + retryTimeout + "ms");
}
}
}
if (headerHidden === false) {
try {
document.querySelector(".stream-wrapper").querySelector("header").style.height = 0;
headerHidden = true;
} catch (error) {
retry = true;
if (retryCount > maxRetries) {
console.error("Could not find the .stream-wrapper header to hide it: " + error);
retry = false;
} else {
console.debug("Could not hide the header, will retry in " + retryTimeout + "ms");
}
}
}
if (gameSelectorMoved === false) {
try {
var gameSelector = document
.querySelector(".stream-wrapper")
.querySelector("header")
.querySelector(".selector");
gameSelector.style.position = "absolute";
gameSelector.style.top = "96%";
gameSelector.style.left = "50%";
gameSelectorMoved = true;
} catch (error) {
retry = true;
if (retryCount > maxRetries) {
console.error("Could not find the .selector to move it: " + error);
retry = false;
} else {
console.debug("Could move the game selector, 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);
}
}