Last active
August 29, 2015 14:04
-
-
Save zvodd/4e4fc42ce4ea13cbedfc to your computer and use it in GitHub Desktop.
Average game times for League of Legends match history display.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_game_times() { | |
var durs = document.querySelectorAll('.date-duration-duration'), | |
games = Array(); | |
for ( i in durs) { | |
var dtxt = durs[i].innerText; | |
if (dtxt != undefined) { | |
// Does it output hours? i have no appplicable data to test. | |
var tar = dtxt.match(/(\d\d):(\d\d)/), | |
tm = Number(tar[1]), | |
ts = Number(tar[2])/60, // convert seconds to percentage | |
t = tm + ts; | |
games.push(t); | |
} | |
} | |
return games; | |
} | |
function summery_text (games, totaltime, sep) { | |
if (sep == undefined){ sep ='\n'; } | |
var average = totaltime/games.length, | |
summery = "Total Time : " +totaltime.toString() + sep + | |
"Number of Games: " + games.length + sep + | |
"Average Time: " + average.toString() + sep + | |
"Note time value format is: '<Minutes>.<SecondsAsAPercentage>'"; | |
return summery; | |
} | |
function sum (ar) { | |
var t = 0; | |
for (var i = 0; i < ar.length; i++) { t += ar[i]; } | |
return t; | |
} | |
var games = get_game_times(), | |
totaltime = sum(games); | |
//alert(games); | |
alert(summery_text(games, totaltime)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment