forked from DavidTDC3377/Remove-twitter-verif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.userscript.js
75 lines (71 loc) · 2.62 KB
/
main.userscript.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
// ==UserScript==
// @name Remove Twitter Blue / X Premium nags and ad revenue ads
// @namespace davidstudios.uk
// @version 1.1-rc
// @description Removes the Eloninization from Twitter
// @author DavidTDC3377/OwnedByWuigi
// @match *://*.twitter.com/* *://*.x.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=x.com
// @grant none
// ==/UserScript==
"use strict";
(() => {
/**
* Calls the provided callback when the document is loaded
*/
function onReady(fn) {
if (document.readyState != "loading") {
fn();
}
else {
document.addEventListener("DOMContentLoaded", fn);
}
}
/**
* Waits for Element added as a descendant of `parent` that matches `selector`.
*/
function waitForElement(parent, selector, callback, runOnce = true) {
const elementNow = parent.querySelector(selector);
if (elementNow) {
callback(elementNow);
if (runOnce) {
return;
}
}
const observer = new MutationObserver((records) => {
records.forEach((record) => {
record.addedNodes.forEach((parentElement) => {
if (parentElement instanceof Element) {
parentElement.querySelectorAll(selector).forEach((element) => {
if (runOnce) {
observer.disconnect();
}
callback(element);
});
}
});
});
});
observer.observe(parent, {
childList: true,
subtree: true,
});
}
onReady(() => {
waitForElement(document, "aside[aria-label='Get Verified']", (element) => { // is this nag still there?
element.parentElement?.remove();
}, false);
waitForElement(document, "aside[aria-label='X Premium']", (element) => {
element.parentElement?.remove();
}, false);
waitForElement(document, "aside[aria-label='Twitter Blue']", (element) => { // just in case elon is lazy, might remove soon
element.parentElement?.remove();
}, false);
waitForElement(document, "aside[aria-label='You may be missing out on ads revenue sharing!']", (element) => {
element.parentElement?.remove();
}, false);
waitForElement(document, "a[aria-label='Verified'][href='/i/verified-choose']", (element) => {
element.remove();
}, false);
});
})();