# Greasemonkey script to replace annoying phrases on the SDMB (e.g. quarry throwing)

**URL:** <https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347>\
**Category:** About This Message Board\
**Created:** [September 20, 2013, 10:51pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347 "2013-09-20T22:51:03Z")\
**Posts on this page:** 1\
**Showing post:** 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:** [September 20, 2013, 10:51pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/1 "2013-09-20T22:51:03Z")

</div>

Below is a script for people who use Greasemonkey in Firefox or Chrome.

Replace any string on the SDMB. Especially useful for frequently occurring annoying phrases. (Especially powerful if you happen to know regular expressions, but still useful if you don’t)

Just edit the “var replacements = {” entry with things you would like to see replaced.

In the two examples below, the quarry-throwing phrase is always replaced by “LOL”. In the first example using a simple string, and in the second example using a regular expression in order to catch several possible versions of the phrase.

```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"
       };

     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;
		 //alert(newHTML);
		 for (var old_str in replacements)
		 {
		     newHTML = newHTML.replace(RegExp(old_str,"mg"), replacements[old_str]);
		 }
		 kids[j].innerHTML = newHTML;
	     }
	 }
     }
 })();

```

---

_[View the full topic](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347)._
