Last active
August 29, 2015 14:07
-
-
Save TagPro-PreciousRoy/0529e6f28ac4cfe6b766 to your computer and use it in GitHub Desktop.
TagPro Events Watcher Userscript
This file contains 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
// ==UserScript== | |
// @name TagPro Events Watcher | |
// @version 0.1 | |
// @description Logs all emitted and received events to/from the TagPro server | |
// @namespace http://www.reddit.com/user/TagProPreciousRoy | |
// @include http://tagpro-maptest.koalabeast.com:* | |
// @include http://tangent.jukejuice.com:* | |
// @include http://maptest.newcompte.fr:* | |
// @include http://tagpro-*.koalabeast.com:* | |
// @copyright 2014+, Precious Roy | |
// ==/UserScript== | |
tagpro.ready(function(){ | |
// p is one too, but it's spammy. | |
events = [ | |
"chat", "mapupdate", "splat", "bomb", "spawn", "id", | |
"settings", "teamNames", "spectator", "spectators", "object", | |
"playerLeft", "map", "time", "sound", "score", "full", | |
"private", "banned", "duplicate", "joinWorld", "end", | |
"groupId", "mapRating", "preferredServer", "sendPreferred", "pr"]; | |
var socketEventHandler = function(eventName){ | |
return function(m){ | |
try{ | |
console.log(eventName, m); | |
}catch(error){ | |
console.log("Error", error); | |
}; | |
} | |
}; | |
for (var i=0; eventName = events[i]; i++){ | |
tagpro.socket.on(eventName, new socketEventHandler(eventName)); | |
} | |
sEmit = tagpro.socket.emit; | |
tagpro.socket.emit = function(){ | |
console.log("Emit:", arguments[0], arguments[1]); | |
return sEmit.apply(this, arguments); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment