Agma Animations Macro

Customize your animation hotkey using chat commands!

Versión del día 28/08/2019. Echa un vistazo a la versión más reciente.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==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
// ==/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: '<dl><dt><b>Commands</b></dt><dd><code>/help</code> | Shows this</dd><dd><code>/settings</code> | Shows your current settings</dd><dd><code>/settings (slot number)</code> | Shows value of given slot</dd><dd><code>/settings (slot number) {animation name}</code> | Sets new animation to given slot</dd></dl>',
                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 <b>' +new1+ '</b>',
                        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 <b>' +new2+ '</b>',
                        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 <b>' +new3+ '</b>',
                        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();
        }
    });