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

**URL:** <https://boards.straightdope.com/t/greasemonkey-script-to-replace-any-string-in-sdmb-threads-e-g-ones-relating-to-quarries/609840>\
**Category:** About This Message Board\
**Created:** [January 17, 2012, 11:15pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-any-string-in-sdmb-threads-e-g-ones-relating-to-quarries/609840 "2012-01-17T23:15:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Polerius](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@Polerius](https://boards.straightdope.com/u/Polerius)\
**Post date:** [January 17, 2012, 11:15pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-any-string-in-sdmb-threads-e-g-ones-relating-to-quarries/609840/1 "2012-01-17T23:15:12Z")

</div>

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

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.

```auto

// ==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](http://boards.straightdope.com/sdmb/showthread.php?t=637351).

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]

---

<div class="post-metadata">

**Author:** ![VinylTurnip](https://avatars.discourse-cdn.com/v4/letter/v/b2d939/32.png) [@VinylTurnip](https://boards.straightdope.com/u/VinylTurnip)\
**Post date:** [January 17, 2012, 11:26pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-any-string-in-sdmb-threads-e-g-ones-relating-to-quarries/609840/2 "2012-01-17T23:26:53Z")

</div>

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

Regards,  
Vinyl

---

<div class="post-metadata">

**Author:** ![bucketybuck](https://avatars.discourse-cdn.com/v4/letter/b/898d66/32.png) [@bucketybuck](https://boards.straightdope.com/u/bucketybuck)\
**Post date:** [January 17, 2012, 11:57pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-any-string-in-sdmb-threads-e-g-ones-relating-to-quarries/609840/3 "2012-01-17T23:57:30Z")

</div>

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

Lol.

---

<div class="post-metadata">

**Author:** ![Jenaroph](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jenaroph](https://boards.straightdope.com/u/Jenaroph)\
**Post date:** [January 18, 2012, 2:23am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-any-string-in-sdmb-threads-e-g-ones-relating-to-quarries/609840/4 "2012-01-18T02:23:52Z")

</div>

> [@bucketybuck](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![ZenBeam](https://avatars.discourse-cdn.com/v4/letter/z/3ab097/32.png) [@ZenBeam](https://boards.straightdope.com/u/ZenBeam)\
**Post date:** [January 19, 2012, 12:40am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-any-string-in-sdmb-threads-e-g-ones-relating-to-quarries/609840/5 "2012-01-19T00:40:46Z")

</div>

OK, this is awesome.
