Betfair Forum Filter

1. FAQ

Q. What is this thing?

A. If you use the Firefox web browser it allows you to automatically remove postings made by selected users on the Betfair forum.

Q. Why would I want to use it?

A. If you find some people on the Betfair forum rather tiresome, it means you won't have to wade through the rubbish they write - you simply won't see it any more.

Q. How does it work?

A. It processes the web pages Betfair's forum server sends to your browser and removes anything written by the users you specify.

Q. How do I know this isn't a Trojan Horse that will steal my Betfair username and password and other personal information?

A. You should indeed be very careful about installing anything on your computer that isn't from a reputable, verifiable source. To be certain that this program doesn't do anything nefarious you would need to look at the program itself, or get someone you know who has a little programming knowledge to do this for you - it is a very short, simple Javascript program.

Q. Why can't I use it with other browsers such as Microsoft's Internet Explorer?

A. I use Firefox so I can't be bothered doing it for other browsers. Firefox is in any case a better browser than Internet Explorer.

Q. Do you provide support for this in case I have problems?

A. I'm not promising anything, but you can usually contact me on the Betfair tennis forum (forum name Siracusa). I don't post to the forum but I do read it.

2. Installation

2.1 Install Firefox

If you do not have the latest version of Firefox installed (version 1.5.0.6 as of 5-Sep-06), download it from http://www.mozilla.com/firefox/ and install it.

2.2 Install Greasemonkey

Run Firefox and install the latest version of Greasemonkey (a Firefox extension) from http://greasemonkey.mozdev.org/. Close Firefox and then restart it.

2.3 Download the filter program

In Firefox, open the filter program and then save it to disk using the File / Save Page As menu option. Do not change the file name betfair_forum_filter.user.js

2.4 Specify the users you wish to exclude

In a text editor or word processing program open the filter program that you saved to disk. The program is:

// =============================================================================
// betfair_forum_filter.user.js
//
// This is a Greasemonkey user script that automatically removes postings
// of specified users from Befair forum threads viewed in the Firefox
// web browser.
//
// BEFORE INSTALLING IT, you must tailor the list of Forum usernames you want 
// to filter in the line beginning 
//              var usernames = 
// in the file below.
//
// You can also remove threads created by these users from the list of
// threads by toggling the filter_thread_list variable from false to true.
//
// To install it, you need the Firefox extension Greasemonkey 
// (http://greasemonkey.mozdev.org/) that allows you to run scripts that 
// alter the web pages you visit. Download Greasemonkey if you don't already
// have it, install it and then restart Firefox. Then open this file in 
// Firefox using File / Open.  On the Tools menu in Firefox, there will be 
// a new menu item "Install This User Script". Choose this menu option to
// install it.
//
// To change the usernames to filter at any time, simply change the list of usernames
// in the
//              var usernames = 
// line, then open the file in your browser using File / Open and then reinstall it
// using Tools / Install This User Script.
//
// You can disable this filter in Firefox without deinstalling it using the 
// Enable checkbox in the Tools / Manage User Scripts window.
//
// To deinstall it, go to Tools / Manage User Scripts, select "Betfair Forum Filter",
// and click Uninstall. 
//
// Tested using Firefox 1.5.0.6 and Greasemonkey 0.6.5.20060727 on Windows XP.
//
// History:
//   04-Sep-06  Siracusa        Created.
// =============================================================================

// ==UserScript==
// @name            Betfair Forum Filter
// @description     Automatically remove postings of obnoxious users from Betfair forum threads.
// @namespace       BetfairForumFilter
// @include         http://forum.betfair.com/*
// ==/UserScript==


// ****** TAILOR THE LIST OF FORUM USERNAMES TO FILTER. THEY MUST BE IN QUOTES AND SEPARATED BY COMMAS. ******
var usernames = [ "Larry Loudmouth", "Harry Halfwit", "Verbal Diarrhoea" ];

// var filter_thread_list = true;
var filter_thread_list = false;

// Find the HTML table containing user postings.
var postings_table = document.evaluate('/HTML[1]/BODY[1]/TABLE[1]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null);
var table = postings_table.singleNodeValue;
var rows = table.rows;
var row, html;

var boldclass = 'class="GlobalBoldedTextWithHand"';     // CSS class for bolding the username in a thread with mouse-over message.
var userclass = 'class="GlobalHand"';                   // CSS class for username mouse-over message in list of threads.

// We must process the rows in reverse order, since the row indices of subsequent rows change when
// we delete a row.
for (var i = rows.length - 1; i > 0; i--) { 
  row = rows[i];
  html = row.innerHTML;
  // See if this table is a thread.
  if  (html.indexOf(boldclass) > 0) {
    for  (var j = 0; j < usernames.length; j++) {
      if  (html.indexOf('>' + usernames[j] + '<') > 0) {
        // Delete this post from the thread. This means this row and the preceding spacer row.
        table.deleteRow(i);
        if (i > 1) {                // The first post has no preceding spacer row.
          table.deleteRow(i-1);
        }
      }
    }
  }
  // or a list of threads.
  else if (html.indexOf(userclass) > 0) {
    if  (filter_thread_list) {
      for  (var j = 0; j < usernames.length; j++) {
        if  (html.indexOf('>' + usernames[j] + '<') > 0) {
          // Delete this thread from the list of threads.
          table.deleteRow(i);
        }
      }
    }
  }
}

You need to change the line highlighted above in red

var usernames = [ "Larry Loudmouth", "Harry Halfwit", "Verbal Diarrhoea" ];

to list the forum usernames of the people whose postings you do not want to see. Just make sure each username is in quotes, as shown, with commas between them. Cut and paste is the best way to go to avoid errors.

Save your changes to disk and exit from the text editor or word processing program (n.b. if you save the changes from a word processing program make sure that you save the file in text format, and that the word processor does not change the file name betfair_forum_filter.user.js - Microsoft Word has a nasty habit of doing this).

2.5 Install the filter program

In Firefox, open the filter program from disk using the File / Open File menu option.

Then use the Tools / Install This User Script menu option to install it.

From now on, when you browse the Betfair forum using Firefox you simply won't see anything these people write.

2.6 Changing the list of users to exclude

You can change the list of users you wish to exclude at any time by simply repeating the steps described in 2.4 Specify the users you wish to exclude and 2.5 Install the filter program.

3. Disabling / Deinstalling

You can disable this filter in Firefox by clearing the Enable checkbox in the Tools / Manage User Scripts window. By disabling it, then reloading the forum page, then re-enabling it and reloading the forum page you can easily see the effect of the filter.

To deinstall it use the Uninstall button in the Tools / Manage User Scripts window in Firefox.

To deinstall Greasemonkey use the Tools / Extensions menu option in Firefox.