Skip to content

Commit 50ce81a

Browse files
author
hannsen
authored
Update TagPro map stats.user.js
1 parent 55a3c34 commit 50ce81a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

TagPro map stats.user.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Tagpro map stats
33
// @namespace https://tagpro.koalabeast.com/
4-
// @version 0.3
4+
// @version 0.4
55
// @description Tagpro map stats duh
66
// @author You
77
// @match https://tagpro.koalabeast.com/game
@@ -25,19 +25,24 @@
2525
waitForLoaded.observe(document.body, config)
2626
}
2727

28+
function ucfirst(string) {
29+
return string.charAt(0).toUpperCase() + string.slice(1);
30+
}
31+
2832
function getMapStat(mapname){
2933
var xhttp = new XMLHttpRequest();
3034
xhttp.onreadystatechange = function() {
3135
if (this.readyState == 4 && this.status == 200) {
32-
var maps = JSON.parse(xhttp.responseText);
33-
var i, x;
34-
var maptypes = ['rotation', 'retired'];
35-
for(x in maptypes){
36-
for(i in maps[maptypes[x]]){
37-
var map = maps.rotation[i];
36+
var allmaps = JSON.parse(xhttp.responseText);
37+
var i, maptype;
38+
for(maptype in allmaps){
39+
var maps = allmaps[maptype];
40+
for(i in maps){
41+
var map = maps[i];
3842
if(map.name == mapname){
39-
var msg = "Map Stats for " + mapname + " / rating: " + map.averageRating + "% / total plays: " + map.totalPlays;
43+
var msg = mapname + " (" + ucfirst(maptype) + " map) / rating: " + map.averageRating + "% / total plays: " + map.totalPlays;
4044
// + (i + 1) + ". place in rotation";
45+
console.log(msg);
4146
setTimeout(function(){
4247
tagpro.socket.emit("chat", {
4348
message: msg,

0 commit comments

Comments
 (0)