Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lethamburn/303685c163084dcb1bed138a68e3d395 to your computer and use it in GitHub Desktop.
Save lethamburn/303685c163084dcb1bed138a68e3d395 to your computer and use it in GitHub Desktop.
Remove Twitter Blue Promotions and TTs
// ==UserScript==
// @name Remove Twitter Blue Promotions + TT's: Spanish Version - @lethamburn
// @namespace https://d23.dev/
// @version 1.0
// @description Elimina el recuadro "Verifícate" de la página de Inicio, el botón "Verificado" de la barra lateral y los Trending Topics de Twitter en Castellano.
// @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='Obtener verificación']", (element) => {
element.parentElement?.remove();
}, false);
waitForElement(document, "a[aria-label='Verificado'][href='/i/verified-choose']", (element) => {
element.remove();
}, false);
waitForElement(document, "div[aria-label='Cronología: Tendencias del momento']", (element) => {
element.remove();
}, false);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment