Last active
August 8, 2016 02:19
-
-
Save cr4m3r/a10cf383c6b201bbe3d4 to your computer and use it in GitHub Desktop.
Chats you current ping with "Shift + P" or loss with "Shift + L" in Tagpro.
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
// ==UserScript== | |
// @name Tagpro Ping and Loss Reporter | |
// @namespace http://www.reddit.com/u/slothbear | |
// @description Reports ping or loss in Tagpro chat (Shift + P, Shift + L) | |
// @include http://tagpro-*.koalabeast.com:* | |
// @include http://tangent.jukejuice.com:* | |
// @include http://*.newcompte.fr:* | |
// @author slothbear / %bodyfat | |
// @version 1.8 | |
// @downloadURL https://gist.github.com/cr4m3r/a10cf383c6b201bbe3d4/raw/tagpro_PingAndLossReporter.user.js | |
// ==/UserScript== | |
tagpro.ready(function () { | |
// SET BUTTONS FOR MACRO HERE (Default is shift + 'p' for ping or 'l' for loss. | |
// You can find key mappings here: https://css-tricks.com/snippets/javascript/javascript-keycodes/ | |
var pingKey = 80; // sets 'p' + shift as the key to report ping. Change the number on this line to keycode of your liking. | |
var lossKey = 76; // sets 'l' + shift as the key to report loss. Change the number on this line to keycode of your liking. | |
document.onkeyup = function (e) { | |
if (tagpro.diableControls || tagpro.spectator) { | |
return; | |
} | |
// REMOVE '&& e.shiftKey' to not use shift as a modifier, or change it to ctrlKey or altKey | |
if (e.keyCode === pingKey && e.shiftKey) { | |
pingReport(); | |
} | |
// REMOVE '&& e.shiftKey' to not use shift as a modifier, or change it to ctrlKey or altKey | |
if (e.keyCode === lossKey && e.shiftKey) { | |
lossReport(); | |
} | |
}; | |
function pingReport() { | |
var pingNumber = tagpro.ping.avg; | |
tagpro.socket.emit("chat", { | |
// SET MESSAGE TO REPORT PING HERE | |
message: ("I have " + pingNumber + " ping right now!"), | |
toAll: true | |
}); | |
} | |
function lossReport() { | |
var lossNumber = tagpro.ping.loss; | |
// lossNumber = lossNumber.toFixed(1); | |
tagpro.socket.emit("chat", { | |
// SET MESSAGE TO REPORT LOSS HERE | |
message: ("I have " + lossNumber + "% loss right now!"), | |
toAll: true | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment