- // ==UserScript==
- // @name BRDTS_KeyboardScript
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @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 (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 (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 北村住宅区--2<br/>\
- 北村公所--3 邮电局--4<br/>\
- 消防署--5 观音堂--6<br/>\
- 清水池--7 西村神社--8<br/>\
- 墓地--9 山丘地带--0<br/>\
- 隧道--- 西村住宅区--q<br/>\
- 寺庙--w 废校--e<br/>\
- 南村神社--r 森林地带--t<br/>\
- 源二郎池--y 南村住宅区--u<br/>\
- 诊所--i 灯塔--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();