Created
July 11, 2014 14:32
-
-
Save theVDude/57982c59a1a5123438c5 to your computer and use it in GitHub Desktop.
Chat Macros for Tagpro!
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 Chat Macros Userscript | |
// @namespace http://www.reddit.com/user/contact_lens_linux/ | |
// @description Help your team with quick chat macros. | |
// @include http://tagpro-*.koalabeast.com:* | |
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html | |
// @author steppin | |
// @version 0.2 | |
// ==/UserScript== | |
(function() { | |
function contentEval(source) { | |
// Check for function input. | |
if ('function' == typeof source) { | |
// Execute this function with no arguments, by adding parentheses. | |
// One set around the function, required for valid syntax, and a | |
// second empty set calls the surrounded function. | |
source = '(' + source + ')();' | |
} | |
// Create a script node holding this source code. | |
var script = document.createElement('script'); | |
script.setAttribute("type", "application/javascript"); | |
script.textContent = source; | |
// Insert the script node into the page, so it will run, and immediately | |
// remove it to clean up. | |
document.body.appendChild(script); | |
document.body.removeChild(script); | |
} | |
function actualScript() { | |
var macros = {} | |
macros[103] = "Their flag carrier is top left!"; | |
macros[104] = "Their flag carrier is top!"; | |
macros[105] = "Their flag carrier is top right!"; | |
macros[100] = "Their flag carrier is to the left!"; | |
macros[101] = "Their flag carrier is in the middle!"; | |
macros[102] = "Their flag carrier is to the right!"; | |
macros[97] = "Their flag carrier is to the bottom left!"; | |
macros[98] = "Their flag carrier is bottom!"; | |
macros[99] = "Their flag carrier is to the bottom right!"; | |
macros[78] = "Want more competitive play? Sign up for NLTP! reddit.com/r/nltp"; | |
macros[88] = "I've got defense!"; | |
macros[90] = "Someone play offense!"; | |
macros[79] = "I've got offense!"; | |
macros[73] = "Attackers Incoming!"; | |
macros[89] = "Yiss"; | |
macros[69] = "Got'em!"; | |
macros[67] = "Please chase their flag carrier so we can score and win!" | |
macros[49] = "Their Carrier is out 1"; // 1 | |
macros[50] = "Their Carrier is out 2"; // 2 | |
macros[51] = "Their Carrier is out 3"; // 3 | |
macros[52] = "Their Carrier is out 4"; // 4 | |
macros[81] = "Their Carrier is contained!"; // Q; | |
macros[82] = "Sorry I killed you :("; // R | |
macros[85] = "Nice job on offense, y'all!"; // U | |
macros[73] = "Nice job on defense, y'all!"; // I | |
$(document).keydown(keypressHandler); | |
var lastMessage = 0; | |
function chat(chatMessage) { | |
var limit = 500 + 10; | |
var now = new Date(); | |
var timeDiff = now - lastMessage; | |
if (timeDiff > limit) { | |
tagpro.socket.emit("chat", { | |
message: chatMessage, | |
toAll: 0 | |
}); | |
lastMessage = new Date(); | |
} else if (timeDiff >= 0) { | |
setTimeout(chat, limit - timeDiff, chatMessage) | |
} | |
} | |
function keypressHandler(event) { | |
var code = event.keyCode || event.which; | |
if (code in macros && !tagpro.disableControls) { | |
chat(macros[code]); | |
//console.log(macros[code]); | |
} | |
} | |
} | |
contentEval(actualScript); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment