# 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:** 20\
**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:** [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;
	     }
	 }
     }
 })();

```

---

<div class="post-metadata">

**Author:** ![Ethilrist](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ethilrist/32/4604_2.png) [@Ethilrist](https://boards.straightdope.com/u/Ethilrist)\
**Post date:** [September 20, 2013, 11:16pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/2 "2013-09-20T23:16:34Z")

</div>

Really? LOL.

Hey, it works!

---

<div class="post-metadata">

**Author:** ![Claverhouse](https://avatars.discourse-cdn.com/v4/letter/c/13edae/32.png) [@Claverhouse](https://boards.straightdope.com/u/Claverhouse)\
**Post date:** [September 20, 2013, 11:23pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/3 "2013-09-20T23:23:24Z")

</div>

‘LOL’ is not annoying ?

---

<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 21, 2013, 12:24am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/4 "2013-09-21T00:24:37Z")

</div>

> [@Claverhouse](#):
>
> ‘LOL’ is not annoying ?

You can replace it with anything you want, including nothing (i.e. ‘’)

---

<div class="post-metadata">

**Author:** ![Tangent](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/tangent/32/3098_2.png) [@Tangent](https://boards.straightdope.com/u/Tangent)\
**Post date:** [September 21, 2013, 12:41am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/5 "2013-09-21T00:41:55Z")

</div>

No more signed posts! Thank you, **Polerius**!  
Enjoy  
Regards  
mmm  
🙂 🙂 🙂 GOD BLESS YOU ALWAYS!!! 🙂 🙂 🙂

---

<div class="post-metadata">

**Author:** ![pricciar](https://avatars.discourse-cdn.com/v4/letter/p/f4b2a3/32.png) [@pricciar](https://boards.straightdope.com/u/pricciar)\
**Post date:** [September 21, 2013, 12:52am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/6 "2013-09-21T00:52:18Z")

</div>

Awesome!  
I just replaced  
“pricciar this is an official warning.” to  
“pricciar that post was amazing, insightful and hilarious. Keep it up!”  
also, “pricciar you are now banned” to  
“pricciar, please create a new screen name to post under, this one is far too popular!”

Thanks!

---

<div class="post-metadata">

**Author:** ![PlainJain](https://avatars.discourse-cdn.com/v4/letter/p/5daacb/32.png) [@PlainJain](https://boards.straightdope.com/u/PlainJain)\
**Post date:** [September 21, 2013, 1:44am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/7 "2013-09-21T01:44:51Z")

</div>

> [@pricciar](#):
>
> Awesome!  
> I just replaced  
> “pricciar this is an official warning.” to  
> “pricciar that post was amazing, insightful and hilarious. Keep it up!”  
> also, “pricciar you are now banned” to  
> “pricciar, please create a new screen name to post under, this one is far too popular!”
> 
> Thanks!

Let’s go to the quarry and throw stuff down there!

---

<div class="post-metadata">

**Author:** ![EmilyG](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/emilyg/32/364_2.png) [@EmilyG](https://boards.straightdope.com/u/EmilyG)\
**Post date:** [September 21, 2013, 1:50am UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/8 "2013-09-21T01:50:45Z")

</div>

Now people won’t have to read my “Am I the only one who…” posts! 😉

---

<div class="post-metadata">

**Author:** ![John\_Mace](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/john_mace/32/185_2.png) [@John\_Mace](https://boards.straightdope.com/u/John_Mace)\
**Post date:** [September 21, 2013, 2:42pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/9 "2013-09-21T14:42:34Z")

</div>

> [@PlainJain](#):
>
> Let’s go to the quarry and throw stuff down there!

LOL, you say?

---

<div class="post-metadata">

**Author:** ![PlainJain](https://avatars.discourse-cdn.com/v4/letter/p/5daacb/32.png) [@PlainJain](https://boards.straightdope.com/u/PlainJain)\
**Post date:** [September 21, 2013, 3:10pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/10 "2013-09-21T15:10:25Z")

</div>

> [@John\_Mace](#):
>
> LOL, you say?

Oops, wrong Greasemokey script…  
😃

---

<div class="post-metadata">

**Author:** ![Rhythmdvl](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@Rhythmdvl](https://boards.straightdope.com/u/Rhythmdvl)\
**Post date:** [September 21, 2013, 4:00pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/11 "2013-09-21T16:00:53Z")

</div>

I just added Pricciar is the kindest, bravest, warmest, most wonderful human being I’ve ever known in my life. I don’t know why. I think I’ll play a game of Minesweeper.

---

<div class="post-metadata">

**Author:** ![SiXSwordS](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@SiXSwordS](https://boards.straightdope.com/u/SiXSwordS)\
**Post date:** [September 21, 2013, 4:12pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/12 "2013-09-21T16:12:35Z")

</div>

> [@Polerius](#):
>
> Below is a script for people who use Greasemonkey in Firefox or Chrome.

I was not familiar with Greasemonkey, or even the option for adding these extensions to Chrome.

Thanks for the script and—especially—the introduction to Greasemonkey!

Now I just need to figure out how to convert :rolleyes: into random [XKCD](http://xkcd.com/196/) links.

---

<div class="post-metadata">

**Author:** ![AaronX](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@AaronX](https://boards.straightdope.com/u/AaronX)\
**Post date:** [September 21, 2013, 4:35pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/13 "2013-09-21T16:35:43Z")

</div>

Don’t you need to consider a huge variety of possibilities? Like spam email?  
Lets go to the quorry and throw stuf down there

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [September 21, 2013, 6:31pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/14 "2013-09-21T18:31:28Z")

</div>

Can someone link to a “Hello World”-level beginner’s tutorial on how to write, install, and use these Greasemonkey thingies?

(Uh, Should I do something like Google it?)

---

<div class="post-metadata">

**Author:** ![Morgenstern](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@Morgenstern](https://boards.straightdope.com/u/Morgenstern)\
**Post date:** [September 21, 2013, 6:41pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/15 "2013-09-21T18:41:50Z")

</div>

˙ǝɹǝɥʇ uʍop ɟɟnʇs ʍoɹɥʇ puɐ ʎɹɹɐnb ǝɥʇ oʇ oƃ s,ʇǝן

---

<div class="post-metadata">

**Author:** ![SiXSwordS](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@SiXSwordS](https://boards.straightdope.com/u/SiXSwordS)\
**Post date:** [September 21, 2013, 7:23pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/16 "2013-09-21T19:23:43Z")

</div>

> [@Senegoid](#):
>
> Can someone link to a “Hello World”-level beginner’s tutorial on how to write, install, and use these Greasemonkey thingies?

[GreaseMonkeyBasics](http://www.techradar.com/us/news/internet/the-beginner-s-guide-to-greasemonkey-scripting-598247)

You need to get the Greasemonkey extension for Firefox, but it’s especially easy if you are using Chrome.

```auto

// ==UserScript==
// @name Hello World
// @namespace SiXSwordS
// @description display Hello World
// @include http://boards.straightdope.com/sdmb/*
// ==/UserScript==

(function()
	{
		var myMessage = "Hello World";
		alert( myMessage );
	})
();

```

Save that code (it’s basically Javascript) and be sure to save your file as someFile.user.js. The @include (and @exclude… which isn’t used here) determines which pages will be affected. My example is pretty annoying because it pops up an alert on every single page on the Dope.

If your include statement were //@include [http://boards.straightdope.com/sdmb/showthread.php?p=16686120](http://boards.straightdope.com/sdmb/showthread.php?p=16686120)\* you would only get the alert in this thread.

On my version of Chrome (29.0.1547.65) you have to go to the far right of the address bar and click the button that looks like three horizontal lines. (In earlier versions, apparently you could just drag and drop the XXX.user.js file into the window.)

Click the button and choose Tools \> Extensions from the dropdown. Drag and drop the XXX.user.js file into the Extensions window. You will have to click ok to allow the script to access the page.

Now, reload and enjoy!

---

<div class="post-metadata">

**Author:** ![SiXSwordS](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@SiXSwordS](https://boards.straightdope.com/u/SiXSwordS)\
**Post date:** [September 21, 2013, 7:27pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/17 "2013-09-21T19:27:45Z")

</div>

In case anyone is interested, I find [W3 schools](http://www.w3schools.com/js/default.asp) to be a good source for basic stuff. The link is a Javascript introduction.  
Oh, and to disable annoying scripts like mine, go back to Tools \> Extensions and disable or trash unwanted scripts.

---

<div class="post-metadata">

**Author:** ![Crazyhorse](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/crazyhorse/32/31_2.png) [@Crazyhorse](https://boards.straightdope.com/u/Crazyhorse)\
**Post date:** [September 21, 2013, 7:36pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/18 "2013-09-21T19:36:49Z")

</div>

I wrote [a similar script](http://boards.straightdope.com/sdmb/showpost.php?p=15260570&postcount=193) a while back to replace annoying signatures with pre-selected phrases.

I haven’t tried this one out yet, but assume it may create a situation similar to one I ran into using my own script: if you quote someone’s post and it changes text within the quote box that is technically against the rules, so use it carefully with that in mind.

---

<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 21, 2013, 9:21pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/19 "2013-09-21T21:21:13Z")

</div>

> [@SiXSwordS](#):
>
> I was not familiar with Greasemonkey, or even the option for adding these extensions to Chrome.
> 
> Thanks for the script and—especially—the introduction to Greasemonkey!
> 
> Now I just need to figure out how to convert :rolleyes: into random [XKCD](http://xkcd.com/196/) links.

Add this line to the definition of the replacements variable 🙂

```auto

  "<img [^>]*src=\"images/smilies/rolleyes.gif\"[^>]*>" : "<a target=\"_blank\" href=\"http://xkcd.com/"+Math.floor((Math.random()*1300)+1)+"\">Random xkcd</a>"

```

---

<div class="post-metadata">

**Author:** ![SiXSwordS](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@SiXSwordS](https://boards.straightdope.com/u/SiXSwordS)\
**Post date:** [September 21, 2013, 9:22pm UTC](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347/20 "2013-09-21T21:22:25Z")

</div>

> [@Crazyhorse](#):
>
> [Quoting] someone’s post… changes text within the quote box that is technically against the rules, so use it carefully with that in mind.

I haven’t had a chance to use this very much yet, but—so far as I can tell—if you use the Post Reply or Quote options (as opposed to Quick Reply) the URL will contain ‘newreply.’ My tests have allowed me to eliminate the script if the URL contains ‘newreply’ but I haven’t tested that beyond the Hello World Script I posted.

[Next page](https://boards.straightdope.com/t/greasemonkey-script-to-replace-annoying-phrases-on-the-sdmb-e-g-quarry-throwing/669347.md?page=2)
