Skip to content

Instantly share code, notes, and snippets.

@nathanpeck
Last active November 10, 2022 05:34
Show Gist options
  • Save nathanpeck/bd48f498e1bc4a2316bd652b85673cc8 to your computer and use it in GitHub Desktop.
Save nathanpeck/bd48f498e1bc4a2316bd652b85673cc8 to your computer and use it in GitHub Desktop.

Revisions

  1. nathanpeck revised this gist Nov 10, 2022. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions twitter-l.js
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,18 @@ function check(changes, observer) {
    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() {
  2. nathanpeck revised this gist Nov 10, 2022. 1 changed file with 11 additions and 15 deletions.
    26 changes: 11 additions & 15 deletions twitter-l.js
    Original file line number Diff line number Diff line change
    @@ -14,25 +14,21 @@
    * @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;
    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) {
    for (const mutation of changes) {
    if (mutation.type === 'childList') {
    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 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);
    }
    }

    (function() {
    'use strict';
    (new MutationObserver(check)).observe(document, {childList: true, subtree: true});
    'use strict';
    (new MutationObserver(check)).observe(document, {childList: true, subtree: true});
    })();
  3. nathanpeck revised this gist Nov 9, 2022. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion twitter-l.js
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,6 @@ function htmlToElement(html) {
    }

    function check(changes, observer) {

    for (const mutation of changes) {
    if (mutation.type === 'childList') {
    var list = document.querySelectorAll('[aria-label="Verified account"]');
  4. nathanpeck revised this gist Nov 9, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions twitter-l.js
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@
    // @version 0.1
    // @description Replace Twitter Verified badge with a fat L
    // @author You
    // @match https://twitter.com/*
    // @icon
    // @grant none
    // ==/UserScript==
    @@ -20,6 +21,7 @@ function htmlToElement(html) {
    }

    function check(changes, observer) {

    for (const mutation of changes) {
    if (mutation.type === 'childList') {
    var list = document.querySelectorAll('[aria-label="Verified account"]');
  5. nathanpeck revised this gist Nov 9, 2022. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion twitter-l.js
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,6 @@ function htmlToElement(html) {
    }

    function check(changes, observer) {

    for (const mutation of changes) {
    if (mutation.type === 'childList') {
    var list = document.querySelectorAll('[aria-label="Verified account"]');
  6. nathanpeck revised this gist Nov 9, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion twitter-l.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    // @version 0.1
    // @description Replace Twitter Verified badge with a fat L
    // @author You
    // @icon
    // @icon
    // @grant none
    // ==/UserScript==

  7. nathanpeck created this gist Nov 9, 2022.
    38 changes: 38 additions & 0 deletions twitter-l.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    // ==UserScript==
    // @name Twitter L's
    // @namespace http://tampermonkey.net/
    // @version 0.1
    // @description Replace Twitter Verified badge with a fat L
    // @author You
    // @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) {

    for (const mutation of changes) {
    if (mutation.type === 'childList') {
    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);
    }
    }
    }
    }

    (function() {
    'use strict';
    (new MutationObserver(check)).observe(document, {childList: true, subtree: true});
    })();