Skip to content

Instantly share code, notes, and snippets.

@nathanpeck
Last active November 10, 2022 05:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanpeck/bd48f498e1bc4a2316bd652b85673cc8 to your computer and use it in GitHub Desktop.
Save nathanpeck/bd48f498e1bc4a2316bd652b85673cc8 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Twitter L's
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Replace Twitter Verified badge with a fat L
// @author You
// @match https://twitter.com/*
// @icon
// @grant none
// ==/UserScript==
/**
* @param {String} HTML representing a single element
* @return {Element}
*/
function htmlToElement(html) {
var template = document.createElement('template');
html = html.trim(); // Never return a text node of whitespace as the result
template.innerHTML = html;
return template.content.firstChild;
}
function check(changes, observer) {
var list = document.querySelectorAll('[aria-label="Verified account"]');
for (var badge of list) {
var altText = htmlToElement("<b style='background-color: #1DA1F2; color: white; padding-left: 4px; padding-right: 4px; margin-left: 5px;'>L</b>");
badge.parentNode.replaceChild(altText, badge);
}
var xpath = "//span[contains(text(),'subscribed to Twitter Blue')]";
var matchingElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (matchingElement) {
matchingElement.innerText = 'This account takes a fat L because they paid for Twitter Blue.';
xpath = "//span[contains(text(),'Verified account')]";
matchingElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (matchingElement) {
matchingElement.innerText = 'Verified L';
}
}
}
(function() {
'use strict';
(new MutationObserver(check)).observe(document, {childList: true, subtree: true});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment