Skip to content

Instantly share code, notes, and snippets.

@angeld23
Last active March 9, 2024 03:23
Show Gist options
  • Save angeld23/b01dd2ef14cd53fc3735fa88f68b7aef to your computer and use it in GitHub Desktop.
Save angeld23/b01dd2ef14cd53fc3735fa88f68b7aef to your computer and use it in GitHub Desktop.
Remove Twitter Blue Promotions: Removes the "Get Verified" box on the Home page and the "Verified" button on the sidebar
// ==UserScript==
// @name Remove Twitter Blue Promotions
// @namespace https://d23.dev/
// @version 1.1
// @description Removes the "Get Verified" box on the Home page and the "Verified" button on the sidebar
// @author angeld23
// @match *://*.twitter.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.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) => {
setTimeout(() => {
element.parentElement?.remove();
}, 100);
}, false);
waitForElement(document, "a[aria-label='Verified'][href='/i/verified-choose']", (element) => {
setTimeout(() => {
element.remove();
}, 100);
}, false);
});
})();
@angeld23
Copy link
Author

angeld23 commented Jul 6, 2023

I went ahead and added a 100ms delay before the element removal which seems to bypass that page-crashing infinite loop some mouthbreather at Twitter added. Let's hope the little lord boy Musky Elon doesn't demand they patch it again

@BombasticMecha
Copy link

Seems they did patch it again, hasn't been working since last night.

@Trimint123
Copy link

Well, it's buffered forever again.

@Glitch3dPenguin
Copy link

It is still not working any longer. 🔢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment