Blogger Jeff = new Blogger

Programming and stuff in Western PA

Firefox and Greasemonkey saved my life, Part 1

I’m addicted to a particular football message board and have been an active participant on there for three years now. Recently, the board, which has a very large member base, has had an invasion of trolls (they’ve practically made the site unreadable). Like most message board software, this site does have an "ignore" feature. What this does is hide the user’s responses by replacing it with a message ("This user is on your ignore list"). However, you can see the ridiculous threads that they’ve created, which is actually the problem in the first place.

To my rescue came a Firefox add-on called Greasemonkey. What GreaseMonkey does is it allows you to interject java script into the html that is returned from a web request. In my case, I had an idea to "hide" from my view posts from these pond scum users.

What I did was save the main page of my message board as html, and then examine it in Visual Studio. I was then able to see the elements of the page, and determine the best manner, via java script and using the page’s DOM to do this. It would have been nice if each post on the page was encapsulated inside a div tag with an id, but I didn’t get off that easy. What I was able to do was look at each table row(<tr>) tag and search for the users name. If it was there, I changed the style for the row to hide it. My entire Greasemonkey script looked like this :

// ==UserScript==
// @name          Unreadability Script
// @namespace     Igglephans
// @description   This script will block out losers
// @include       http://igglephans.com/*
// ==/UserScript==

var users="jerrybim2,ericcoe,robbie76";
var ary = users.split(",");
var trHtml="";
var item;
var o=document.getElementsByTagName("tr");

for (var i = o.length - 1; i >= 0; i--){
	item=o.item(i);

	trHtml=item.innerHTML;

	for (var z = ary.length - 1; z >= 0; z--){
		if(trHtml.search(ary[z])!=-1)
			item.style.display="none";
	};
};

Tags: ,

Advertisements

December 8, 2007 - Posted by | Firefox, Technology

3 Comments »

  1. firfox is really , a helpful application . i always like that !

    Comment by Website Promotion | December 8, 2007 | Reply

  2. Thanks so much. Using what I found here, I was able to finally silence a horrible troll on one of the boards I frequent.

    I can’t tell you how much this has helped.

    THANKS!!!!

    Comment by GeoBain | February 4, 2008 | Reply

  3. OH. MY. GOD. This is exactly what I have been looking for! I will see if it works. THANK YOU.

    Comment by Daniel | March 21, 2008 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: