-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
42 lines (35 loc) · 1.02 KB
/
content.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
function removeElonized(loadingDogeSvg, logoDogeSvg) {
loadingDogeSvg?.remove();
logoDogeSvg?.remove();
}
const observer = new MutationObserver((mutationsList) => {
let loadingDogeSvg, logoDogeSvg;
for (const mutation of mutationsList) {
if (mutation.type === "childList" && mutation.addedNodes.length) {
if (!loadingDogeSvg) {
loadingDogeSvg = document.querySelector(
'div[aria-label*="Loading"]#placeholder > svg'
);
}
if (!logoDogeSvg) {
logoDogeSvg = document.querySelector(
'a[aria-label="Twitter"] > div > svg'
);
}
if (loadingDogeSvg || logoDogeSvg) {
removeElonized(loadingDogeSvg, logoDogeSvg);
}
// Disconnect the observer if both elements are removed
if (loadingDogeSvg && logoDogeSvg) {
observer.disconnect();
}
}
}
});
observer.observe(document.querySelector("body"), {
childList: true,
subtree: true,
});
document.addEventListener("beforeunload", () => {
observer.disconnect();
});