tv.com episode renumber

By mungushume Last update Jan 12, 2008 — Installed 171 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
// ==UserScript==
// @author         mungushume
// @version        1.0.1
// @name           tv.com episode renumber
// @namespace      http://www.monkeyr.com
// @description    Re-numbers the episodes of a show so each seasons first episode starts as episode 1
// @include        http://www.tv.com/*/episode_guide.html*
// @include        http://www.tv.com/*/episode_listings.html*
// @scriptsource   http://userscripts.org/scripts/show/19798
// ==/UserScript==

/* 

v1.0.1 - 12 Jan 2007
 - Bug fix: "Special" episodes are not now re-numbered i.e. http://www.tv.com/family-guy/show/348/episode_guide.html?season=6
 - Feature: Now also works on Episode Lists

v1.0.0 - 11 Jan 2008
 - Initial release.
 
*/



var list = document.evaluate ("//h1[@class='f-18 f-666']|//td[@class='first f-bold ta-c']", document, null, 
								XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); 	
for (var i = 0, j = 1; i < list.snapshotLength; i++)
{
	var node = list.snapshotItem(i).childNodes[0];
	
	if (!isNaN(node.textContent)){
		node.textContent = j++ + '. ';
	}
}