diff --git a/Source/content_script.js b/Source/content_script.js index a34d9d18..0bd71944 100644 --- a/Source/content_script.js +++ b/Source/content_script.js @@ -1,4 +1,5 @@ walk(document.body); +document.title = buttify(document.title); function walk(node) { @@ -29,11 +30,9 @@ function walk(node) } } -function handleText(textNode) { - var v = textNode.nodeValue; - +function buttify(text) { // Deal with the easy case - v = v.replace(/\b(T|t)he (C|c)loud/g, function(match, p1, p2, offset, string) { + text = text.replace(/\b(T|t)he (C|c)loud/g, function(match, p1, p2, offset, string) { // t - 7 = m // c - 1 = b m = String.fromCharCode(p1.charCodeAt(0) - 7); @@ -42,23 +41,25 @@ function handleText(textNode) { }); // Deal with private clouds - v = v.replace(/\b(P|p)rivate (C|c)loud/g, function(match, p1, p2, offset, string) { + text = text.replace(/\b(P|p)rivate (C|c)loud/g, function(match, p1, p2, offset, string) { // c - 1 = b b = String.fromCharCode(p2.charCodeAt(0) - 1); return b + "utt"; }); // Get the corner cases - if(v.match(/cloud/i)) { + if(text.match(/cloud/i)) { // If we're not talking about weather - if(v.match(/PaaS|SaaS|IaaS|computing|data|storage|cluster|distributed|server|hosting|provider|grid|enterprise|provision|apps|hardware|software|/i)) { - v = v.replace(/(C|c)loud/gi, function(match, p1, offset, string) { + if(text.match(/PaaS|SaaS|IaaS|computing|data|storage|cluster|distributed|server|hosting|provider|grid|enterprise|provision|apps|hardware|software|/i)) { + text = text.replace(/(C|c)loud/gi, function(match, p1, offset, string) { // c - 1 = b b = String.fromCharCode(p1.charCodeAt(0) - 1); return b + "utt"; }); } } - textNode.nodeValue = v; + return text; } - +function handleText(textNode) { + textNode.nodeValue = buttify(textNode.nodeValue); +}