Since Elon Musk became Twitter’s CEO, he’s been pushing through a lot of changes to the social network. But perhaps…

  • crowsby@kbin.social
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    1 year ago

    I can do you one better with a Tampermonkey script that will replace every reference to his name on every webpage to either “the biggest twat on the planet” or “this dipshit”, depending on which works better syntactically.

    // ==UserScript==
    // @name         Text Replace
    // @version      0.1
    // @description  Text Replace
    // @author       SiameseDream
    // @include     *
    // @grant        none
    // @namespace beepboop
    // ==/UserScript==
    
    (function() {
        'use strict';
    
    var replaceArry = [
        [/ Elon Musk/gi,' the biggest twat on the planet'],
        [/Elon Musk/gi,'The biggest twat on the planet'],
        [/ Mr. Musk/gi,' this dipshit'],
        [/ Musk/gi,' this dipshit'],
        [/Mr. Musk/gi,'This dipshit'],
        [/Musk/gi,'This dipshit'],
        // etc.
    ];
    var numTerms    = replaceArry.length;
    var txtWalker   = document.createTreeWalker (
        document.body,
        NodeFilter.SHOW_TEXT,
        {   acceptNode: function (node) {
                //-- Skip whitespace-only nodes
                if (node.nodeValue.trim() )
                    return NodeFilter.FILTER_ACCEPT;
    
                return NodeFilter.FILTER_SKIP;
            }
        },
        false
    );
    var txtNode     = null;
    
    while (txtNode  = txtWalker.nextNode () ) {
        var oldTxt  = txtNode.nodeValue;
    
        for (var J  = 0;  J < numTerms;  J++) {
            oldTxt  = oldTxt.replace (replaceArry[J][0], replaceArry[J][1]);
        }
        txtNode.nodeValue = oldTxt;
    }
    })();
    
    

    In practice it looks like this