Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name TagPro No-Script Macros
- // @description Macros for no-script groups (updated for swj)
- // @version 0.1.1
- // @author Some Ball -1
- // @include *://*.koalabeast.com*
- // @include http://tagpro-*.koalabeast.com:*
- // @include http://tagpro*.koalabeast.com*
- // @run-at document-end
- // @grant unsafeWindow
- // ==/UserScript==
- (function(window) {
- 'use strict';
- if(!window.tagpro) {
- // Number on left side is the keyCode of the key you want to trigger the macro
- // Get keyCodes from here: http://keycode.info/
- // message should contain the message you want to send in quotes
- // sendTo should be 0, 1, or 2 to send the message to everyone, your team, your group, respectively
- const macros = {
- 73: {message: "Sample message to all players", sendTo: 0}, // I
- 79: {message: "Sample message to team", sendTo: 1}, // O
- 80: {message: "Sample message to group", sendTo: 2}, // P
- };
- /////////////////////////////////////////////////////
- const chatTo = [13, 84, 71]; //shouldn't need to change, default enter=13, t=84, g=71
- function pressUnpress(key) {
- $(document).trigger($.Event('keydown',{keyCode: key, fake: true})); //fake so we don't trigger our own events
- $(document).trigger($.Event('keyup',{keyCode: key, fake: true}));
- }
- //use e.which instead of e.keyCode because key remapper script changes e.keyCode
- $(document).keydown(function(e) {
- if(!e.fake && macros.hasOwnProperty(e.which) && e.originalEvent && !e.originalEvent.repeat && !$('#chat').is(':visible')) {
- let macro = macros[e.which];
- pressUnpress(macro.hasOwnProperty("sendTo") && macro.sendTo>=0 && macro.sendTo<chatTo.length ? chatTo[macro.sendTo] : chatTo[0]);
- $('#chat').val(macro.message || "");
- pressUnpress(13); //enter to send
- }
- });
- }
- })(unsafeWindow);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement