// Sportsline Ads Remover (c) Craig J Copi (craig@copi.org)
// Turn narrow tables into wide tables.  We set a lower limit on the
//   size of tables we will expand. We do not adjust any relative width
//   tables, only fixed width. Background images are also removed.
// ==UserScript==
// @name          Sportsline Ads Remover
// @namespace     http://craig.copi.org/greasemonkey/
// @description   Removes ad column from sportsline.com
// @include       http://*.sportsline.com/*
// @exclude       http://*.sportsline.com/*/story/*
// ==/UserScript==

/* Find the ad using XPath. It is a td with class adtitle buried in
 * cascading tables.  The pattern is the same though the levels of
 * tables differs amongst the pages. */
var items = document.evaluate(
  "//td[@class = \"adtitle\"]",
  document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

//alert ("Found "+items.snapshotLength);
/* Loop over the entries we found.  The one we want is buried as
 * TD/TABLE/TBODY/TR/TD/TABLE/TBODY/TR/TD[@class="adtitle"]
 * so we walk up 8 levels and look for a TD.  We remove it if found.
 */
for (var i=0; i < items.snapshotLength; ++i) {
  var item = items.snapshotItem(i);
  var c = 0;
  while (item && c < 8) {
    item = item.parentNode;
    ++c;
  }
//  alert ("item name = "+item.tagName+"::"+i);
  if (item && item.tagName.match("TD")) {
//alert ("Removing node"+item.nodeName+":"+item.data+":"+item.nodeType+":"+item.nodeValue+"|");
    item.parentNode.removeChild (item);
  }
}

