Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Nothing before the 'but' counts
- // @namespace nothingbeforethebut
- // @description Replaces the string "I'm not Xist, but" with "I'm Xist, and"
- // @include *
- // @version 1.0.0
- // @grant none
- // ==/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(/\b(I|i)'?m not (\w)ist,? but/gi, "I'm $2ist, and");
- textNode.nodeValue = v;
- }
- walk(document.getElementsByTagName('body')[0]);
- walk(document.getElementsByTagName('title')[0]);
- }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement