octolusnet / Easy editing & Deleting

// ==UserScript==
// @name         Easy editing & Deleting
// @namespace    https://octolus.net
// @version      1.0
// @description  Added ability to press "Arrow Up" to edit shout - or "DEL/DELETE" to delete shout rapidly.
// @author       Octolus
// @match        http://www.nextgenupdate.com/forums/
// @grant        none
// ==/UserScript==
//document.onkeydown = checkKey;

function checkKey(e) {
    e = e || window.event;
    if (e.keyCode == '38') {
        $.get("infernoshout.php", function(data, status){
            //var myString = 'ondblclick="InfernoShoutboxControl.edit_shout(12034766);"><s';
            if(status == 'success')
            {
                data = data.getElementsByTagName('data')[0].firstChild.data;
                data = data.split(InfernoShoutboxControl.parsebreaker);
                var res = data[0].match(/edit_shout\(([0-9]*)\)/);
                if(res === null)
                {
                    InfernoShoutboxControl.show_notice('We couldn\'t find your shout! Something went wrong..');
                }
                else
                {
                    //console.log('We grabbed shout ID: ' + res[1]);
                    InfernoShoutboxControl.edit_shout(res[1]);
                    console.log(res[1]);
                }
            }
            else
            {
                InfernoShoutboxControl.show_notice('Sorry, we couldn\'t find your latest shout!');
            }
        });
    }
    else
        if(e.keyCode == '46')
        {
            $.get("infernoshout.php", function(data, status){
            //var myString = 'ondblclick="InfernoShoutboxControl.edit_shout(12034766);"><s';
            if(status == 'success')
            {
                data = data.getElementsByTagName('data')[0].firstChild.data;
                data = data.split(InfernoShoutboxControl.parsebreaker);
                var res = data[0].match(/edit_shout\(([0-9]*)\)/);
                if(res === null)
                {
                    InfernoShoutboxControl.show_notice('We couldn\'t find your shout! Something went wrong..');
                }
                else
                {
                    $.post("infernoshout.php",
                    {
                        do: "doeditshout",
                        shoutid: res[1],
                        delete: 1,
                        securitytoken: SECURITYTOKEN
                    },
                    function(data, status){
                        if(data == 'completed')
                        {
                            InfernoShoutboxControl.show_notice('Deleted');
                        }
                        else if(data == 'too_old_to_modify')
                        {
                            InfernoShoutboxControl.show_notice('Damn! You are too late out, the 8 second limit beat ya.');
                        }
                        else
                        {
                            InfernoShoutboxControl.show_notice('Uknown error, check JS Console.');
                            console.log('Inferno Status:' + status);
                            console.log('Inferno Data:' + data);
                        }
                    });
                }
            }
            else
            {
                InfernoShoutboxControl.show_notice('Sorry, we couldn\'t find your latest shout!');
            }
        });

        }
    }

    $('#vbshout_pro_shoutbox_editor').keyup(function(){checkKey();});