// ==UserScript==
// @name           Replace Text
// @namespace      org.dopiaza.greasemonkey.replacetext
// @description    Replace text
// @include        http://tvlistings.zap2it.com/tvlistings/ZCGrid.do
// ==/UserScript==

var replacements, regex, key, textnodes, node, s; 
replacements = 
{   
"^2$": "2-0",
"^4$": "4-1",
"^5$": "5-1",
"^6$": "16-1",
"^7$": "7-1",
"^8$": "103-4",
"^9$": "9-1",
"^10$": "79-8", 
"^11$": "111-2", 
"^12$": "28-1", 
"^13$": "13-1", 
"^16$": "116-10", 
"^17$": "116-9", 
"^19$": "91-8",  
"^21$": "117-1049", 
"^24$": "116-1", 
"^25$": "116-2", 
"^27$": "102-9",
"^30$": "102-5",
"^31$": "102-6",
"^32$": "91-1",
"^33$": "91-2",
"^34$": "91-3",
"^35$": "92-6",
"^36$": "116-83",
"^37$": "91-5",
"^38$": "103-5",
"^39$": "91-6",
"^40$": "91-7",
"^41$": "80-5",
"^42$": "91-9",
"^43$": "116-83",
"^44$": "116-7",
"^45$": "116-12",
"^46$": "91-10",
"^47$": "92-1",
"^48$": "92-2",
"^49$": "92-3",
"^50$": "103-3",
"^51$": "92-4",
"^52$": "92-5",
"^53$": "103-2",
"^54$": "92-7",
"^55$": "92-8",
"^56$": "103-1",
"^57$": "103-6",
"^58$": "92-9",
"^59$": "103-7",
"^60$": "103-9",
"^61$": "103-10",
"^62$": "92-10",
"^63$": "103-10",
"^64$": "102-40",
"^65$": "102-2",
"^66$": "102-3",
"^67$": "103-8",
"^68$": "102-7",
"^70$": "116-8",
"^74$": "dunno",
"^75$": "75-0",
"^76$": "76-0",
"^77$": "77-0",
"^78$": "78-0",
"^96$": "dunno",
"^99$": "79-6"}; 
regex = {}; 
for (key in replacements) 
{ 
	regex[key] = new RegExp(key, 'g'); 
} 

var nodes = document.evaluate( 
"//span[@class='zc-st-n']", 
document, 
null, 
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, 
null);

//alert(nodes.snapshotLength);

for (var i = 0; i < nodes.snapshotLength; i++) 
{ 
    node = nodes.snapshotItem(i); 
    s = node.innerHTML; 
    for (key in replacements) 
    { 
         s = s.replace(regex[key], replacements[key]); 
    } 
    node.innerHTML = s; 
} 