Last active
November 5, 2015 05:05
-
-
Save cr4m3r/58a1d524d996399cc379 to your computer and use it in GitHub Desktop.
Chats random words and phrases ('Shift + D' is default trigger)
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 Random Chat Macro | |
// @namespace http://www.reddit.com/u/slothbear | |
// @description Chats random words and phrases | |
// @include http://tagpro-*.koalabeast.com:* | |
// @include http://tangent.jukejuice.com:* | |
// @include http://*.newcompte.fr:* | |
// @license whatever brah! | |
// @author slothbear / %bodyfat | |
// @version 1.5 | |
// comment out 'at'downloadurl so user settings won't change on update anymore https://gist.github.com/cr4m3r/58a1d524d996399cc379/raw/tagpro_RandomChatMacro.user.js | |
// ==/UserScript== | |
tagpro.ready(function () { | |
//if (tagpro.group.socket) | |
// return; | |
var phrases = [ | |
/************************************************* | |
* SET RANDOM PHRASES BELOW | |
* | |
* ALL PHRASES MUST BE BETWEEN QUOTATION MARKS | |
* AND BE FOLLOWED BY A COMMA (BUT NO COMMA ON | |
* THE LAST PHRASE) | |
* | |
* EXAMPLE: "RANDOM PHRASE", | |
* "ANOTHER RANDOM PHRASE", | |
* | |
* DON'T PUT ANY PHRASES ABOVE OR BELOW DOTTED LINES | |
**************************************************/ | |
// ---------------------------- | |
// --- RANDOM PHRASES BELOW --- | |
// ---------------------------- | |
"doot doot", | |
"2Spooky4Sloppy", | |
"Got Calcium?", | |
"watch this!", | |
"My ball is broken", | |
"Who let the dogs out?", | |
"Thanks Obama!", | |
"do you even tagBro?", | |
// Remember, no comma after last phrase | |
"Origin, more like Bore-igin" | |
// ---------------------------- | |
// --- RANDOM PHRASES ABOVE --- | |
// ---------------------------- | |
]; | |
// ******************************************************** | |
// SET TRIGGER FOR CHAT MACRO HERE (Default is 'SHIFT + D') | |
// You can find key mappings here: https://css-tricks.com/snippets/javascript/javascript-keycodes/ | |
// The number in the next line represents the 'D' key | |
// Change to your preference | |
var triggerKey = 68; //sets 'D' as a key | |
// ******************************************************** | |
var lastChatTime = 666; | |
document.onkeydown = function (randomEvent) { | |
if (tagpro.disableControls || tagpro.spectator) { | |
return; | |
} | |
// NEXT LINES SET SHIFT, CTRL, OR ALT AS MODIFIER KEY | |
// Uncomment corresponding line by removing '//' infront of the 'if' under the key you want | |
// then put '//' in front of the 'if's corresponding to the keys you don't want | |
//SHIFT | |
// if (randomEvent.keyCode === triggerKey && randomEvent.shiftKey) { | |
//CTRL | |
// if (randomEvent.keyCode === triggerKey && randomEvent.ctrlKey) { | |
//ALT | |
// if (randomEvent.keyCode === triggerKey && randomEvent.altKey) { | |
//NO MODIFIER KEY | |
if (randomEvent.keyCode === triggerKey){ | |
//------------------------------------------------------------------------ | |
var randomPhrase = phrases[Math.floor(Math.random() * phrases.length)]; | |
chatter(randomPhrase); | |
} | |
}; | |
function chatter(phrase) { | |
if (timeCheck()) { | |
tagpro.socket.emit("chat", { | |
message: phrase, | |
toAll: true | |
}); | |
lastChatTime = Date.now(); | |
} | |
} | |
// Won't chat within 5000ms of last chat | |
function timeCheck() { | |
var timeDifference = Date.now() - lastChatTime; | |
return (timeDifference > 5000 || lastChatTime === 666); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment