Greasemonkey script to replace any string in SDMB threads (e.g. ones relating to quarries)

Below is a greasemonkey script to replace some strings that you may find annoying, e.g. ones having to do with quarries :slight_smile:

FYI, for those who don’t know, greasemonkey is an add-on for Firefox and Chrome that allows you to install some scripts in your browser to implement simple utilities. Consult greasemonkey help on how to install new scripts.



// ==UserScript==
// @name           Replace any string on SDMB
// @namespace      Polerius
// @description    Replace any string in threads on SDMB
// @include        http://boards.straightdope.com/sdmb/*
// ==/UserScript==

(function() 
 {
     var replacements = {
         "Let's go to the quarry and throw stuff down there"                              : "LOL",
         "Let's go (down )?to the quarry and throw (shit|stuff) (down|in) (there|here)"   : "LOL",
         "Foo"                                                                            : "Bar",
         "another string"                                                                 : "replacement string"
       };

     var allPosts    = document.getElementsByClassName('alt1');

     for (var i = 0; i < allPosts.length; i++)
     {
	 var kids = allPosts*.children;
	 for (var j=0; j<kids.length; j++)
	 {
	     if (kids[j].id.match(/^post_message_/))
	     {
		 var newHTML = kids[j].innerHTML;
		 for (var old_str in replacements)
		 {
		     newHTML = newHTML.replace(RegExp(old_str,"g"), replacements[old_str]);
		 }
		 kids[j].innerHTML = newHTML;
	     }
	 }
     }
 })();


Once installed, you can try the code on this thread.

Note
[ul]
[li]You can edit the code describing “var replacements” to add your own strings and their replacements.[/li][li]The strings that are to be replaced can be literal strings (like the first entry in replacements) or for those of you who know how to use them, can be regular expressions (like the second entry in replacements).[/li][/ul]

Good tip. I’ve long used a similar script to transform a certain poster’s complimentary closing into something far more appropriate.

Regards,
Vinyl

So we can make that retarded quarry thing appear as “LOL”?

Lol.

Given the explanation of how that particular meme started, that’s pretty damned funny.

OK, this is awesome.