File tree 1 file changed +13
-8
lines changed
1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 1
1
// ==UserScript==
2
2
// @name Tagpro map stats
3
3
// @namespace https://tagpro.koalabeast.com/
4
- // @version 0.3
4
+ // @version 0.4
5
5
// @description Tagpro map stats duh
6
6
// @author You
7
7
// @match https://tagpro.koalabeast.com/game
25
25
waitForLoaded . observe ( document . body , config )
26
26
}
27
27
28
+ function ucfirst ( string ) {
29
+ return string . charAt ( 0 ) . toUpperCase ( ) + string . slice ( 1 ) ;
30
+ }
31
+
28
32
function getMapStat ( mapname ) {
29
33
var xhttp = new XMLHttpRequest ( ) ;
30
34
xhttp . onreadystatechange = function ( ) {
31
35
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 ] ;
38
42
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 ;
40
44
// + (i + 1) + ". place in rotation";
45
+ console . log ( msg ) ;
41
46
setTimeout ( function ( ) {
42
47
tagpro . socket . emit ( "chat" , {
43
48
message : msg ,
You can’t perform that action at this time.
0 commit comments