BRDTS_KeyboardScript

BR大逃杀全键盘操作脚本

当前为 2015-12-13 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         BRDTS_KeyboardScript
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  BR大逃杀全键盘操作脚本
// @author       StingX
// @match        http://123.57.37.3/*
// @match        http://www.dtsgame.com/*
// @require      http://code.jquery.com/jquery-1.11.0.min.js
// ==/UserScript==

function postCommand(mode,command){
    if(arguments.length){
    $('#submit').attr("disabled",true);
    var oXmlHttp = zXmlHttp.createRequest();
    var sBody = 'mode='+mode+'&command='+command+'&=%E6%8F%90%E4%BA%A4';
    oXmlHttp.open("post", "command.php", true);
    oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                showGamedata(oXmlHttp.responseText);
                $('#submit').attr("disabled",false);
            } else {
                showNotice(oXmlHttp.statusText);
            }
        }
    };
    oXmlHttp.send(sBody);
    }
    else{
         $('#submit').attr("disabled",true);
    var oXmlHttp = zXmlHttp.createRequest();
    var sBody = getRequestBody(document.forms['cmd']);
    oXmlHttp.open("post", "command.php", true);
    oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    oXmlHttp.onreadystatechange = function () {
        if (oXmlHttp.readyState == 4) {
            if (oXmlHttp.status == 200) {
                showGamedata(oXmlHttp.responseText);
                $('#submit').attr("disabled",false);
            } else {
                showNotice(oXmlHttp.statusText);
            }
        }
    };
    oXmlHttp.send(sBody);   
        
    }
}

//展开select
function open(elem) {
    if (document.createEvent) {
        var e = document.createEvent("MouseEvents");
        e.initMouseEvent("mousedown", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
        elem[0].dispatchEvent(e);
    } else if (element.fireEvent) {
        elem[0].fireEvent("onmousedown");
    }
}

var scroll = {
    '!' : function() { 
            postCommand('special','pose0'); 
        }, 
    '@' : function() { 
            postCommand('special','pose1'); 
        }, 
    '#' : function() { 
           postCommand('special','pose2'); 
        }, 
    '$' : function() { 
            postCommand('special','pose3'); 
        }, 
    '%' : function() { 
            postCommand('special','pose4'); 
        }, 
    '^' : function() { 
            postCommand('special','pose5'); 
        }, 
    'Q' : function() { 
            postCommand('special','tac0'); 
        }, 
    'W' : function() { 
            postCommand('special','tac2'); 
        }, 
    'E' : function() { 
            postCommand('special','tac3'); 
        }, 
    'R' : function() { 
            postCommand('special','tac4'); 
        }, 
        '1' : function() { 
            $("select[name='moveto']").val(1);
            sl('move');
            postCommand(); 
        }, 
        '2' : function() { 
            $("select[name='moveto']").val(2);
            sl('move');
            postCommand(); 
        }, 
        '3' : function() { 
            $("select[name='moveto']").val(3);
            sl('move');
            postCommand(); 
        }, 
        '4' : function() { 
            $("select[name='moveto']").val(4);
            sl('move');
            postCommand(); 
        }, 
        '5' : function() { 
            $("select[name='moveto']").val(5);
            sl('move');
            postCommand(); 
        }, 
        '6' : function() { 
            $("select[name='moveto']").val(6);
            sl('move');
            postCommand(); 
        }, 
        '7' : function() { 
            $("select[name='moveto']").val(7);
            sl('move');
            postCommand(); 
        }, 
        '8' : function() { 
            $("select[name='moveto']").val(8);
            sl('move');
            postCommand(); 
        }, 
        '9' : function() { 
            $("select[name='moveto']").val(9);
            sl('move');
            postCommand(); 
        }, 
        '0' : function() { 
            $("select[name='moveto']").val(10);
            sl('move');
            postCommand(); 
        }, 
        '-' : function() { 
            $("select[name='moveto']").val(11);
            sl('move');
            postCommand(); 
        }, 
        'q' : function() { 
            $("select[name='moveto']").val(12);
            sl('move');
            postCommand(); 
        }, 
        'w' : function() { 
            $("select[name='moveto']").val(13);
            sl('move');
            postCommand(); 
        }, 
        'e' : function() { 
            $("select[name='moveto']").val(14);
            sl('move');
            postCommand(); 
        }, 
        'r' : function() { 
            $("select[name='moveto']").val(15);
            sl('move');
            postCommand(); 
        }, 
        't' : function() { 
            $("select[name='moveto']").val(16);
            sl('move');
            postCommand(); 
        }, 
        'y' : function() { 
            $("select[name='moveto']").val(17);
            sl('move');
            postCommand(); 
        }, 
        'u' : function() { 
            $("select[name='moveto']").val(18);
            sl('move');
            postCommand(); 
        }, 
        'i' : function() { 
            $("select[name='moveto']").val(19);
            sl('move');
            postCommand(); 
        }, 
        'o' : function() { 
            $("select[name='moveto']").val(20);
            sl('move');
            postCommand(); 
        }, 
        'p' : function() { 
            $("select[name='moveto']").val(21);
            sl('move');
            postCommand(); 
        },
        ' ':function() { 
            postCommand(); 
        },
        'a':function() { 
            sl('search_');
            postCommand(); 
        },
    //left
        '37':function() { 
            var radios =  $("input[type='radio']");
            var checkedIndex;
            radios.each(function(i,e){
                if(e.checked){
                    checkedIndex = i;
                    return false;
                }
            });
            radios.get(checkedIndex+1).click();
        },
    //up
        '38':function() { 
            var radios =  $("input[type='radio']");
            var checkedIndex;
            radios.each(function(i,e){
                if(e.checked){
                    checkedIndex = i;
                    return false;
                }
            });
            if(checkedIndex>0)
                radios.get(checkedIndex-1).checked = true;
            else
                radios.get(radios.length-1).checked = true;

        },
    //right
    '39':function() { 
            var radios =  $("input[type='radio']");
            var checkedIndex;
            radios.each(function(i,e){
                if(e.checked){
                    checkedIndex = i;
                    return false;
                }
            });
           open(radios.eq(checkedIndex).next().children().first());
        },
    //down
        '40':function() { 
            var radios =  $("input[type='radio']");
            var checkedIndex;
            radios.each(function(i,e){
                if(e.checked){
                    checkedIndex = i;
                    return false;
                }
            });
            if(checkedIndex<radios.length-1)
                radios.get(checkedIndex+1).checked = true;
            else
                radios.get(0).checked = true;
        },
    };



var run =function () {
    create_right();
    

    
    window.addEventListener('keydown',
        function(e) {
            if ($('#chatmsg').is(':focus')||($('input[name="buynum"]').length&&$('input[name="buynum"]').is(':focus'))||e.metaKey || e.ctrlKey   || e.target.isContentEditable || document.designMode ==="on") {
                                console.log('block key2');
                return; }
            if (e.keyCode<37||e.keyCode>40)
                return;
            if (scroll[e.keyCode]) {
                scroll[e.keyCode]();
                e.preventDefault();
                e.stopPropagation();
            }
        }, false);
        window.addEventListener('keypress',
        function(e) {
            if ($('#chatmsg').is(':focus')||($('input[name="buynum"]').length&&$('input[name="buynum"]').is(':focus'))||e.metaKey || e.ctrlKey   || e.target.isContentEditable || document.designMode ==="on") {
                console.log('block key1');
                return; }
            var key =  String.fromCharCode(e.charCode);
            if (scroll[key]) {
                scroll[key]();
                e.preventDefault();
                e.stopPropagation();
            }
        }, false);
}



function create_right(){
    if($("td[rowspan='2']").length>0){
$("td[rowspan='2']").parent().append("\
<td rowspan=\"2\">         <table border=\"1\" width=\"250\" height=\"550\" cellspacing=\"0\" cellpadding=\"0\">     \
<tbody>             <tr><td valign=\"top\" class=\"b3\" style=\"text-align: left\">                 <div id=\"log\">                 <span class=\"yellow b\" style=\"letter-spacing: 2px;\">\
基础快捷键:<br/>\
选择--方向键↑→↓,Esc<br/>\
提交,确定--空格<br/>\
探索--a<br/>\
<br/>\
移动:<br/>\
北海岸--1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;北村住宅区--2<br/>\
北村公所--3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;邮电局--4<br/>\
消防署--5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;观音堂--6<br/>\
清水池--7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;西村神社--8<br/>\
墓地--9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;山丘地带--0<br/>\
隧道---&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;西村住宅区--q<br/>\
寺庙--w&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;废校--e<br/>\
南村神社--r&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;森林地带--t<br/>\
源二郎池--y&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;南村住宅区--u<br/>\
诊所--i&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;灯塔--o<br/>\
南海岸--p<br/>\
<br/>\
基础姿态:<br/>\
通常--shift+1<br/>\
攻击姿态--shift+2<br/>\
防守姿态--shift+3 <br/>\
探索姿态--shift+4<br/>\
隐藏姿态--shift+5 <br/>\
治疗姿态--shift+6 <br/>\
<br/>\
应战策略:<br/>\
通常--shift+q<br/>\
重视防御 --shift+w<br/>\
重视反击 --shift+e<br/>\
重视躲避 --shift+r<br/>\
</span><br>                 </div>                                  </td>             </tr>         </tbody></table>         </td>");
    }
}


run();