Agma Animations Macro

Customize your animation hotkey using chat commands!

À partir de 2019-08-28. Voir la dernière version.

Vous devrez installer une extension telle que Tampermonkey, Greasemonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Userscripts pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension de gestionnaire de script utilisateur pour installer ce script.

(J'ai déjà un gestionnaire de scripts utilisateur, laissez-moi l'installer !)

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

(J'ai déjà un gestionnaire de style utilisateur, laissez-moi l'installer!)

// ==UserScript==
// @name         Agma Animations Macro
// @namespace    http://tampermonkey.net/
// @version      0.2.2
// @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') {
            swal({
                title: 'Current Settings',
                type: 'info',
                text: '<b>Slot 1</b>: '+JSON.parse(localStorage.getItem("aam"))[0]+'<br><b>Slot 2</b>: '+JSON.parse(localStorage.getItem("aam"))[1]+'<br><b>Slot 3</b>: '+JSON.parse(localStorage.getItem("aam"))[2],
                html: true
            })
            $(".sweet-alert p").css({
                textAlign: 'left',
                color: 'white'
            });
            $("dd").css({
                marginLeft: '10px'
            });
            $(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({
                        textAlign: 'center',
                        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({
                        textAlign: 'center',
                        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({
                        textAlign: 'center',
                        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({
                        textAlign: 'center',
                        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({
                        textAlign: 'center',
                        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({
                        textAlign: 'center',
                        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();
        }
    });