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.
// ==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;
}
}
}
})();
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!”
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.
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.
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.
In case anyone is interested, I find W3 schools 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.
I wrote a similar script 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.
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.