This repository has been archived by the owner on Feb 13, 2023. It is now read-only.
forked from giantdwarf17/Discord-M1
-
Notifications
You must be signed in to change notification settings - Fork 5
/
discord-downloadapps-icon.js
99 lines (88 loc) · 2.67 KB
/
discord-downloadapps-icon.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
// This is the download app icon
function findDownloadAppsIconWrapper(stopElement) {
let downloadAppsSVG = document.querySelector(
'[data-list-item-id="guildsnav___app-download-button"]'
);
while (
downloadAppsSVG !== null &&
downloadAppsSVG.parentElement !== null &&
downloadAppsSVG.parentElement !== stopElement
) {
if (
downloadAppsSVG.parentElement.nodeName === 'DIV' &&
downloadAppsSVG.parentElement.className.includes('listItem-')
) {
return downloadAppsSVG.parentElement;
}
downloadAppsSVG = downloadAppsSVG.parentElement;
}
}
// This is the small line above download apps.
function findGuildSepeartor(startElement) {
let parentOfGuildSeperator = null;
for (let i = 0; i < startElement.children.length; i++) {
const child = startElement.children[i];
if (child.className.includes('scroller-')) {
parentOfGuildSeperator = child;
break;
}
}
if (parentOfGuildSeperator) {
for (let i = parentOfGuildSeperator.children.length - 1; i > 0; i--) {
const child = parentOfGuildSeperator.children[i];
if (
child &&
child.firstChild &&
child.firstChild.className.includes('guildSeparator-')
) {
return child;
}
}
}
return undefined;
}
let foundDownloadIconRemoved = false;
let foundGuildSeperatorRemoved = false;
function tryRemoveAppIcon() {
setTimeout(function () {
// Getting the top element in the SideBar and using that as a stopper for the loops.
// This will make sure that if we cant find the data, then it wont run forever.
let sideBar = document.querySelector('[data-list-id="guildsnav"]');
if (sideBar) {
const foundDownloadIcon = findDownloadAppsIconWrapper(sideBar);
const foundGuildSeperator = findGuildSepeartor(sideBar);
if (foundDownloadIcon) {
foundDownloadIcon.style.display = 'none';
foundDownloadIconRemoved = true;
}
if (foundGuildSeperator) {
foundGuildSeperator.style.display = 'none';
foundGuildSeperatorRemoved = true;
}
}
if (!foundDownloadIconRemoved || !foundGuildSeperatorRemoved) {
tryRemoveAppIcon();
}
}, 250);
}
tryRemoveAppIcon();
document.addEventListener('click', (e) => {
// when the user clicks log out then start searching again!
if (e.target) {
// check if its the button that is clicked or if its the div inside the button
const clicked =
e.target.nodeName === 'BUTTON' ? e.target : e.target.parentElement;
if (
clicked &&
clicked.nodeName === 'BUTTON' &&
clicked.getAttribute('type') === 'submit' &&
/^.*?\bbutton-\b.*?\blookFilled-\b.*?colorRed-\b.*?sizeMedium-\b.*?grow-\b.*?$/.test(
clicked.className
)
) {
foundDownloadIconRemoved = false;
foundGuildSeperatorRemoved = false;
tryRemoveAppIcon();
}
}
});