diff --git a/CloudToButt.xpi b/CloudToButt.xpi index 40e7bc0..e26bd5d 100644 Binary files a/CloudToButt.xpi and b/CloudToButt.xpi differ diff --git a/src/chrome/content/cloud-to-butt.js b/src/chrome/content/cloud-to-butt.js index 8d41e9f..c52eef7 100644 --- a/src/chrome/content/cloud-to-butt.js +++ b/src/chrome/content/cloud-to-butt.js @@ -1,43 +1,65 @@ (function() { - function walk(node) - { - // I stole this function from here: - // http://is.gd/mwZp7E - - var child, next; - - switch ( node.nodeType ) - { - case 1: // Element - case 9: // Document - case 11: // Document fragment - child = node.firstChild; - while ( child ) - { - next = child.nextSibling; - walk(child); - child = next; - } - break; - - case 3: // Text node +function walk(node) +{ + // I stole this function from here: + // http://is.gd/mwZp7E + + var child, next; + + switch ( node.nodeType ) + { + case 1: // Element + case 9: // Document + case 11: // Document fragment + child = node.firstChild; + while ( child ) + { + next = child.nextSibling; + walk(child); + child = next; + } + break; + + case 3: // Text node + if(node.parentElement.tagName.toLowerCase() != "script") { handleText(node); - break; - } - } - - function handleText(textNode) - { - var v = textNode.nodeValue; + } + break; + } +} - 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 v = textNode.nodeValue; + + // Deal with the easy case + v = v.replace(/\b(T|t)he (C|c)loud/g, function(match, p1, p2, offset, string) { + // t - 7 = m + // c - 1 = b + var m = String.fromCharCode(p1.charCodeAt(0) - 7); + var b = String.fromCharCode(p2.charCodeAt(0) - 1); + return m + "y " + b + "utt"; + }); + + // Deal with private clouds + v = v.replace(/\b(P|p)rivate (C|c)loud/g, function(match, p1, p2, offset, string) { + // c - 1 = b + var b = String.fromCharCode(p2.charCodeAt(0) - 1); + return b + "utt"; + }); + // Get the corner cases + if(v.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) { + // c - 1 = b + var b = String.fromCharCode(p1.charCodeAt(0) - 1); + return b + "utt"; + }); } + } + textNode.nodeValue = v; +} function windowLoadHandler() { diff --git a/src/install.rdf b/src/install.rdf index 753a062..7ac051d 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -3,25 +3,25 @@ - cloud-to-butt@github.com + cloud-to-butt-mozilla@github.com 2 Cloud To Butt - Replaces the text 'the cloud' with 'my butt'. - Steven Frank - Chris Wright - https://github.com/DaveRandom/cloud-to-butt-mozilla + Replaces the text 'cloud' with 'butt'. + Dan Bunyard + Dan Bunyard + https://github.com/danodemano/cloud-to-butt-mozilla - 1.0 + 1.1 {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 4.0 - 999.* + 30.0