Skip to content

Instantly share code, notes, and snippets.

@kalmanolah
Last active March 4, 2021 07:58
Show Gist options
  • Save kalmanolah/5764435 to your computer and use it in GitHub Desktop.
Save kalmanolah/5764435 to your computer and use it in GitHub Desktop.
Replaces instances of "(The) Cloud" with "(My) Butt". Ported from and Inspired by panicsteve's cloud-to-butt extension for Google Chrome, and DaveRandom's ports thereof.
// ==UserScript==
// @name Cloud to Butt
// @namespace cloudtobutt
// @description Replaces instances of "(The) Cloud" with "(My) Butt". Ported from and Inspired by panicsteve's cloud-to-butt extension for Google Chrome, and DaveRandom's ports thereof.
// @include *
// @version 1.0.1
// @grant none
// @updateURL https://gist.github.com/kalmanolah/5764435/raw/cloudtobutt.user.js
// ==/UserScript==
(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
handleText(node);
break;
}
}
function handleText(textNode)
{
var v = textNode.nodeValue;
v = v.replace(/\bthe cloud\b/gi, "my butt");
v = v.replace(/\bThe Cloud\b/gi, "My Butt");
v = v.replace(/\bThe cloud\b/gi, "My butt");
v = v.replace(/\bthe Cloud\b/gi, "my Butt");
v = v.replace(/\bTHE CLOUD\b/gi, "MY BUTT");
v = v.replace(/\bcloud\b/gi, "butt");
v = v.replace(/\bCloud\b/gi, "Butt");
v = v.replace(/\bCLOUD\b/gi, "BUTT");
textNode.nodeValue = v;
}
walk(document.getElementsByTagName('body')[0]);
walk(document.getElementsByTagName('title')[0]);
}());
@nloveladyallen
Copy link

It i flag in the expressions makes them case-insensitive, defeating the purpose of the eight different expressions. Removing them preserves correct capitalization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment