Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arfie/02ef14602317fe58a099 to your computer and use it in GitHub Desktop.
Save arfie/02ef14602317fe58a099 to your computer and use it in GitHub Desktop.
Chats you current ping with "Shift + P" or loss with "Shift + L" in Tagpro.
// ==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:*
// @license whatever brah!
// @author slothbear / %bodyfat / Ruud
// @version 1.8
// @downloadURL https://gist.github.com/cr4m3r/a10cf383c6b201bbe3d4/raw/tagpro_PingAndLossReporter.user.js
// ==/UserScript==
tagpro.ready(function () {
//if (tagpro.group.socket) {
// console.log("GROUP.SOCKET is TRUE");
// return;
//} else {
// console.log("GROUP.SOCKET is FALSE");
//};
// 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) {
var t = e.target.nodeName.toLowerCase();
if (t == 'input' || t == 'textarea')
return;
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 " + (100 * lossNumber).toFixed(1) + "% loss right now!"),
toAll: true
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment