chrome.extension.sendMessage({}, function(response) {
    var readyStateCheckInterval = setInterval(function() {
        if (document.readyState === "complete") {
            clearInterval(readyStateCheckInterval);
            main();
        }
    }, 10);

    function main() {
        // Replace page title
        document.title = generateReplacment(document.title);

        // Create a tree walker to traverse all text nodes
        var walker = document.createTreeWalker(
            document.body,
            NodeFilter.SHOW_TEXT,
            null,
            false
        );

        // Replace all text nodes
        var textNode;
        while(!!(textNode = walker.nextNode())) {
            textNode.nodeValue = generateReplacment(textNode.nodeValue);
        }
    }

    function generateReplacment(text) {
        const regex = /Donald( (John|J|J.))? Trump/gi;

        const adjectives1 = [
            "Large",
            "Tiny",
            "Wilting",
            "Bulbous"
        ];

        const adjectives2 = [
            "Orange",
            "Greasy",
            "Decayed"
        ];

        const nouns = [
            "Corn Cob",
            "Hand Gnome",
            "Butternet Squash"
        ];

        // TODO: perform with a single replace command
        return text.replace(regex, getName()).replace("Trump", "Drumpf");

        function getName() {
            var name = getRandomElement(adjectives1)
            if(Math.random() > 0.5) name  += " " + getRandomElement(adjectives2)
            return name + " " + getRandomElement(nouns);
        }

        function getRandomElement(array) {
            return array[Math.floor(Math.random()*array.length)];
        }
    }

});


@@ -361,24 +361,676 @@
 nt.title);%0A%0A
+        // Replace all initial text on page%0A        replaceNodeText(document.body);%0A%0A        // Create a mutation observer to monitor the DOM for changes%0A        var observer = new MutationObserver(function(mutations) %7B%0A            mutations.forEach(function(mutation) %7B%0A                Array.prototype.slice.call(mutation.addedNodes).forEach(replaceNodeText);%0A            %7D);%0A        %7D);%0A%0A        // Configure and start the observer%0A        observer.observe(document.body, %7B%0A            childList: true,%0A            subtree: true,%0A            attributes: false,%0A            characterData: false%0A        %7D);%0A    %7D%0A%0A    function replaceNodeText(node) %7B%0A
         // C
@@ -1068,32 +1068,32 @@
  all text nodes%0A
-
         var walk
@@ -1136,29 +1136,20 @@
         
-document.body
+node
 ,%0A      

use MutationObserver to monitor dom and update new nodes