Parab00n
Joined: 04 Jan 2009 Posts: 3
|
Posted: Sun Jan 04, 2009 5:02 pm Post subject: Pulling Winning Streaks |
|
|
I was passed on a Script that automatically goes in and pulls all the current winning streaks over 19 games. However, I was trying to get the results to display a little differently and so far I can't seem to get it to do so. Any help would be greatly appreciated.
| Code: | // ==UserScript==
// @name Winning Streaks
// @namespace GLB
// @include http://goallineblitz.com/game/leagues.pl
// ==/UserScript==
//Find all the leagues
var longWinStreaks = Array();
docsQueued = 0;
window.xpath = function(query, node) {
return document.evaluate(query, node, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
}
window.getDocument = function(url) {
docsQueued++;
GM_xmlhttpRequest( {
method: 'GET',
url: url,
headers: {
'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
'Accept': 'text/xml',
},
onload: function(responseDetails) {
findWinStreaks(responseDetails.responseText);
docsQueued--;
if(docsQueued==0)
{
for(index = 0; index < longWinStreaks.length; index++)
{
contentElement.innerHTML += longWinStreaks[index] + "<br/>";
}
contentElement.innerHTML += "<br/><br/>";
for(index = 0; index < longLosingStreaks.length; index++)
{
contentElement.innerHTML += longLosingStreaks[index] + "<br/>";
}
}
}
} );
}
window.findWinStreaks = function(doc) {
var div = document.createElement("div");
div.style.display = "none";
div.innerHTML = doc;
teamLinks = xpath(".//div//div[contains(@id,'conferences')]//div//table//tr//td//a[contains(@href, '/game/team.pl?team_id=')]", div);
league = xpath(".//div//div//a[contains(@href,'/game/league.pl?league_id=')]", div);
//nextGameTime = xpath(".//div//div[contains(@innerHTML,'Next sim in')]");
for(var teamIndex = 0; teamIndex < teamLinks.snapshotLength; teamIndex++)
{
streak = teamLinks.snapshotItem(teamIndex).parentNode.parentNode.childNodes[7].innerHTML;
indexOfW =streak.indexOf("W");
if(indexOfW != -1)
{
if(streak.substring(1) > 19)
{
longWinStreaks.push(teamLinks.snapshotItem(teamIndex).parentNode.parentNode.childNodes[3].innerHTML
+ ":" + teamLinks.snapshotItem(teamIndex).parentNode.parentNode.childNodes[7].innerHTML
+ " : " + league.snapshotItem(0).innerHTML + " : " );
}
}
}
}
contentElement = document.getElementById("content");
leagueLinks = xpath(".//div//a[contains(@href, '/game/league.pl?league_id=')]", contentElement);
for(var leagueIndex = 0; leagueIndex < leagueLinks.snapshotLength; leagueIndex++)
{
getDocument(leagueLinks.snapshotItem(leagueIndex).href);
} |
|
|