Worse Than Youtube Comments

No Comments
I like Youtube, but reading Youtube comments is like performing trepanation on your own head with a pencil eraser. I tell myself not to read them, but often they are in all caps, so they sneak into my brain anyway. I struggled with this pain for months before coming to a stunning realization: I can block Youtube comments with a tiny Greasemonkey script! However, simply shutting off comments didn't fill me with joy and hope. Fortunately, while discussing the dilemma with Zach, the solution presented itself: reduce the text of each comment to "Bla bla bla..." Genius! It may even have been Zach's idea. I searched the web a bit until I found a script to donate some code -- feyntube replaces Youtube comments with quotes from Richard Feynman. Of course there is very little of the original code left, because I wanted each word to be replaced with a "bla" -- hopefully with similar capitalization and punctuation. Before: Picture 4 Wow, this is fairly egregiously nonsensical. After: Picture 3 Here's the code, with copious comments.
// ==UserScript==
// @name          Youtube blablabla
// @namespace     http://jpmullan.com
// @description   transform YouTube comments into reasonable and smart ones
// @include       http://*youtube*/*
// ==/UserScript==

// Based on feyntube, Written 2008 by Julien Oster <feyntube@julien-oster.de>,
// find the newest version at http://www.julien-oster.de/projects/feyntube

function blanode(node) {
    var text = "";
    // if the node has children, loop through them
    if (node.hasChildNodes()) {
	var children = node.childNodes;
	for (var i=0; i < children.length; i++) {
	    blanode(children[i]);
	}
    } else if (node.nodeName == "#text") {
	node.oldText = node.nodeValue;
	node.newText = blatext(node.nodeValue);
	node.nodeValue = node.newText;
	/* Uncomment the following if you hate life only a little and want a
	 * reason to end it, like the ability to see the source text of
	 * comments.  I do not recommend this course of action, but it is there.
	 */
	/*
	  node.parentNode.addEventListener('mouseover', function (event) {
	  node.nodeValue = node.oldText;
	  }, false)
	  node.parentNode.addEventListener('mouseout', function (event) {
	  node.nodeValue = node.newText;
	  }, false);
	*/
    }
    return text;
}
			    
function blatext(input_string) {
    /* split the input on word boundaries */
    var input_parts = input_string.split(/\b/);
    var output_string = '';
    var part;
    for (var j = 0; j < input_parts.length; j++) {
	part = input_parts[j];
	if (part.match(/^[A-Z]+$/)) {
	    /* words that are all caps */
	    output_string += 'BLA';
	} else if (part.match(/^[A-Z]\w+$/)) {
	    /* words that are capitalized */
	    output_string += 'Bla';
	} else if (part.match(/^[a-z][a-z]+$/)) {
	    /* words that are all lowercase and have more than one character
	     * this leave possessives and the like intact, so you get bla's
	     * instead of bla'bla, which is the wrong kind of funny */
	    output_string += 'bla';
	} else if ('I' == part) {
	    /* self reference?  whatever */
	    output_string += 'Bla';
	} else if (part.match(/^[0-9]+th$/)) {
	    /* fix ordinal numbers! */
	    output_string += 'blath';
	} else if (part.match(/^[0-9]+rd$/)) {
	    output_string += 'blard';
	} else if (part.match(/^[0-9]+st$/)) {
	    output_string += 'blast';
	} else {
	    /* Okay, that's plenty.  Anything else would be just mean. */
	    output_string += part;
	}
    }
    return output_string;
}

var allDivs = document.getElementsByTagName('div');
for (var i = 0; i < allDivs.length; i++) {
    div = allDivs[i];
    if (div.hasAttribute('class')
	&& div.getAttribute('class').match(/commentBody/)) {
	blanode(div);
    }
}
That's the meat of it, but this isn't a programming magazine from the 1980s that requires you to type ten thousand lines of BASIC into your C64 -- this is the internet, and it is full of many magicks. If you are the type of person to enjoy a good greasemonkey script from time to time, you might enjoy this one: http://jpmullan.com/greasemonkey/youtubeblablabla.user.js But wait there's more! I read Boing Boing, and they have comments, too. Most of the time their commenters are smart and reasonable people, but occasionally I read something from some troll on there that makes me temporarily lose my mind. I could just block specific people, but then I might still be caught unawares. The solution is to nuke the site from orbit. It's the only way to be sure. Before: Picture 2 After: Picture 1 http://jpmullan.com/greasemonkey/boingboingblablabla.user.js

Be the first to write a comment!