(via kottke)

Bailout, Barry and Levon Style

While not as useful as Jeb’s beloved hipster replacement greasemonkey script, this one is a bit more timely. I’m as worried as the next guy about the current financial crisis, but sometimes I just want to put my blinders on when I read the news.

Thus, I present a spoonful of scripting to help that morning New York Times go down a bit easier:

// Based on a script in Mark Pilgram's upcoming "Dive into Greasemonkey",
// based off another script based off that

// ==UserScript== 
// @name          ignorebailout
// @namespace     http://modcult.org/userscripts
// @description   Hide from reality.
// @include       *
// ==/UserScript== 


(function() {
    var replacements, regex, key, textnodes, node, s; 

    replacements = { 
        "bailout": "balls out",
        "Bailout": "Balls out",
        "(\\$[0-9]+ +billion)": "$1 worth of pudding"
    }; 

    regex = {}; 
    for (key in replacements) { 
        regex[key] = new RegExp(key, 'g'); 
    } 

    textnodes = document.evaluate( "//body//text()", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); 

    for (var i = 0; i < textnodes.snapshotLength; i++) { 
        node = textnodes.snapshotItem(i); 
        s = node.data; 
        for (key in replacements) { 
            s = s.replace(regex[key], replacements[key]); 
        } 
        node.data = s; 
    } 

})();

shouldn’t that be $240 worth of pudding?


that’s a matched pattern, so it will be however much pudding congress wants to give.