Greasy Fork is available in English.
Customize your animation hotkey using chat commands!
当前为
// ==UserScript==
// @name Agma Animations Macro
// @namespace http://tampermonkey.net/
// @version 0.1.1
// @description Customize your animation hotkey using chat commands!
// @author Nuke
// @match http://agma.io/
// @grant 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) {
alert("Commands: /help (Shows this) || /settings [animation slot (max 3)] {animation name} || If you use /settings without any arguments it will show your current settings || If you use /settings but with a slot number, it will reset that slot. ALSO IF YOU GET NO ALERT WHEN DOING AN COMMAND, IT MEANS THAT IT WORKED!")
$(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 = "";
}
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));
}
else if (value[10] === '2') {
var new2 = "";
if (value.length === 11) {
new2 = "";
}
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));
}
else if (value[10] === '3') {
var new3 = "";
if (value.length === 11) {
new3 = "";
}
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));
} else if (value[10] > 3) {
alert("Invalid slot: " + value[10] + " || Max slots = 3")
}
$(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();
}
});