// ==UserScript== // @name Agma Animations Macro // @namespace http://tampermonkey.net/ // @version 0.2.0 // @description Customize your animation hotkey using chat commands! // @author Nuke // @match http://agma.io/ // @grant none // @downloadURL none // ==/UserScript== var aam_settings; if (!localStorage.getItem("aam")) { aam_settings = ["","",""]; localStorage.setItem("aam", JSON.stringify(aam_settings)); } else { console.log(JSON.parse(localStorage.getItem("aam"))); } $("#chtbox").on("keydown", function(e){ var value = $(this).val(); if ($(this).is(":focus") && e.keyCode == '13') { e.preventDefault(); if (value.indexOf('/help') > -1) { swal({ title: 'Help', type: 'info', text: '
Commands
/help | Shows this
/settings | Shows your current settings
/settings (slot number) | Shows value of given slot
/settings (slot number) {animation name} | Sets new animation to given slot
', html: true }) $(".sweet-alert p").css({ textAlign: 'left', color: 'white' }); $("dd").css({ marginLeft: '10px' }); $(this).val(""); } if (value == '/settings') { alert("Slot 1: " + JSON.parse(localStorage.getItem("aam"))[0] + " || Slot 2: " + JSON.parse(localStorage.getItem("aam"))[1] + " || Slot 3: " + JSON.parse(localStorage.getItem("aam"))[2]); $(this).val(""); } else if (value.indexOf('/settings ') > -1) { if (value[10] === '1') { var new1 = ""; if (value.length === 11) { new1 = ""; swal({ title: 'Slot Reset', type: 'info', text: 'Slot 1 has been reset' }) $(".sweet-alert p, .sweet-alert h2").css({ color: 'white' }) } else { if (value.indexOf('wacky') > -1) { new1 = "wacky"; } else if (value.indexOf('spin') > -1) { new1 = "spin"; } else if (value.indexOf('flip') > -1) { new1 = "flip"; } else if (value.indexOf('shake') > -1) { new1 = "shake"; } else if (value.indexOf('jump') > -1) { new1 = "jump"; } aam_settings = [new1, JSON.parse(localStorage.getItem("aam"))[1], JSON.parse(localStorage.getItem("aam"))[2]]; localStorage.setItem("aam", JSON.stringify(aam_settings)); swal({ title: 'Slot Updated', type: 'success', text: 'Slot 1 has been changed to ' +new1+ '', html: true }) $(".sweet-alert p, .sweet-alert h2").css({ color: 'white' }) } } else if (value[10] === '2') { var new2 = ""; if (value.length === 11) { new2 = ""; swal({ title: 'Slot Reset', type: 'info', text: 'Slot 2 has been reset' }) $(".sweet-alert p, .sweet-alert h2").css({ color: 'white' }) } else { if (value.indexOf('wacky') > -1) { new2 = "wacky"; } else if (value.indexOf('spin') > -1) { new2 = "spin"; } else if (value.indexOf('flip') > -1) { new2 = "flip"; } else if (value.indexOf('shake') > -1) { new2 = "shake"; } else if (value.indexOf('jump') > -1) { new2 = "jump"; } aam_settings = [JSON.parse(localStorage.getItem("aam"))[0], new2, JSON.parse(localStorage.getItem("aam"))[2]]; localStorage.setItem("aam", JSON.stringify(aam_settings)); swal({ title: 'Slot Updated', type: 'success', text: 'Slot 2 has been changed to ' +new2+ '', html: true }) $(".sweet-alert p, .sweet-alert h2").css({ color: 'white' }) } } else if (value[10] === '3') { var new3 = ""; if (value.length === 11) { new3 = ""; swal({ title: 'Slot Reset', type: 'info', text: 'Slot 3 has been reset' }) $(".sweet-alert p, .sweet-alert h2").css({ color: 'white' }) } else { if (value.indexOf('wacky') > -1) { new3 = "wacky"; } else if (value.indexOf('spin') > -1) { new3 = "spin"; } else if (value.indexOf('flip') > -1) { new3 = "flip"; } else if (value.indexOf('shake') > -1) { new3 = "shake"; } else if (value.indexOf('jump') > -1) { new3 = "jump"; } aam_settings = [JSON.parse(localStorage.getItem("aam"))[0], JSON.parse(localStorage.getItem("aam"))[1], new3]; localStorage.setItem("aam", JSON.stringify(aam_settings)); swal({ title: 'Slot Updated', type: 'success', text: 'Slot 3 has been changed to ' +new3+ '', html: true }) $(".sweet-alert p, .sweet-alert h2").css({ color: 'white' }) } } else if (value[10] > 3) { swal({ title: 'Error!', type: 'error', text: 'The max amount of slots is 3!' }) $(".sweet-alert p, .sweet-alert h2").css({ color: 'white' }) } $(this).val(""); } } }) window.addEventListener('keydown', function(event) { if (event.keyCode == '192' && ! event.shiftKey) { var items = JSON.parse(localStorage.getItem("aam")); $('#chtbox').val('/' + items[0] + items[1] + items[2]).focus(); event.preventDefault(); } });