Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions Source/content_script.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
walk(document.body);

function walk(node)
{
// I stole this function from here:
// http://is.gd/mwZp7E

var child, next;

switch ( node.nodeType )
Expand All @@ -27,16 +25,32 @@ function walk(node)
}
}

function handleText(textNode)
{
var v = textNode.nodeValue;

v = v.replace(/\bThe Cloud\b/g, "My Butt");
v = v.replace(/\bThe cloud\b/g, "My butt");
v = v.replace(/\bthe Cloud\b/g, "my Butt");
v = v.replace(/\bthe cloud\b/g, "my butt");

textNode.nodeValue = v;
}


function handleText(textNode){
var textArray = [{
originalText: "The Cloud",
updatedText: "My Butt"
},{
originalText: "The cloud",
updatedText: "My butt"
}, {
originalText: "the Cloud",
updatedText: "my Butt"
}, {
originalText: "the cloud",
updatedText: "my butt",
}
];

for (var enumeration = textArray.length - 1; enumeration >= 0; enumeration--) {
// console.log(textArray[enumeration]);
var nodeTextToFix = textNode.nodeValue;

var huntedPhrase = new RegExp(textArray[enumeration].originalText, "g")


textNode.nodeValue = nodeTextToFix.replace(huntedPhrase, textArray[enumeration].updatedText);
};
}
walk(document.body);