如何从键盘事件变为鼠标事件
How to change from keyboard events to mouse events
下面的代码被编程为监听键盘事件,但我想将其更改为监听鼠标按钮。例如,我不想用 Q 快速进给,而是想用鼠标右键,而不是用 space 拆分,我想用鼠标左键,有人能帮忙吗?
// ==UserScript==
// @name Best Tricksplit, Doublesplit, and Feeding Macros + Auto Settings + Triplesplit Macro
// @namespace http://tampermonkey.net/
// @version 0.9
// @description Sets show mass and dark theme to true, provides a tricksplit with E or 4, triplesplit with 3, doublesplit with D or 2, faster feeding with Q, and split with 1
// @author Jack Burch + Tom Burris
// @match http://abs0rb.me/*
// @match http://agar.io/*
// @match http://agarabi.com/*
// @match http://agarly.com/*
// @match http://en.agar.bio/*
// @match http://agar.pro/*
// @match http://agar.biz/*
// @grant none
// @run-at document-end
// ==/UserScript==
window.addEventListener('keydown', keydown);
window.addEventListener('keyup', keyup);
var Feed = false;
var Dingus = false;
var imlost = 25;
load();
function keydown(event) {
if (event.keyCode == 81) {
Feed = true;
setTimeout(F, imlost);
} // Tricksplit
if (event.keyCode == 16) {
i();
setTimeout(i, imlost);
setTimeout(i, imlost*2);
setTimeout(i, imlost*3);
} // Doublesplit
if (event.keyCode == 18 ) {
i();
setTimeout(i, imlost);
}// Split
if (event.keyCode == 32) {
i();
}
} // When Player left Q, It Stop Feeding fast
function keyup(event) {
if (event.keyCode == 81) {
Feed = false;
}
if (event.keyCode == 79) {
Dingus = false;
}
}
// Feed Macro With Q
function F() {
if (Feed) {
window.onkeydown({keyCode: 87});
window.onkeyup({keyCode: 87});
setTimeout(F, imlost);
}
}
function i() {
$("body").trigger($.Event("keydown", { keyCode: 32}));
$("body").trigger($.Event("keyup", { keyCode: 32}));
}
经过我朋友的一些研究和帮助,我发现代码应该更改为如下所示
// ==UserScript==
// @name saqar
// @namespace http://tampermonkey.net/
// @version 0.9
// @description Sets show mass and dark theme to true, provides a tricksplit with E or 4, triplesplit with 3, doublesplit with D or 2, faster feeding with Q, and split with 1
// @author Jack Burch + Tom Burris
// @match http://abs0rb.me/*
// @match http://3rb.be/*
// @match http://agar.io/*
// @match http://agarabi.com/*
// @match http://cell.sh/*
// @match http://agarly.com/*
// @match http://en.agar.bio/*
// @match http://agar.pro/*
// @match http://agar.biz/*
// @grant none
// @run-at document-end
// ==/UserScript==
window.addEventListener('keydown', keydown);
window.addEventListener('keyup', keyup);
window.addEventListener('mousedown', mousedown);
window.addEventListener('mouseup', mouseup);
window.addEventListener('contextmenu', discm);
var Feed = false;
var Dingus = false;
var imlost = 25;
load();
function keydown(event) {
if (event.keyCode == 81) {
Feed = true;
setTimeout(F, imlost);
} // Tricksplit
if (event.keyCode == 16) {
i();
setTimeout(i, imlost);
setTimeout(i, imlost*2);
setTimeout(i, imlost*3);
setTimeout(i, imlost*4);
} // Doublesplit
if (event.keyCode == 18 ) {
i();
setTimeout(i, imlost);
}// Split
if (event.keyCode == 32) {
i();
}
} // When Player left Q, It Stop Feeding fast
function keyup(event) {
if (event.keyCode == 81) {
Feed = false;
}
if (event.keyCode == 79) {
Dingus = false;
}
}
// Split with left mouse btn
function mousedown(event) {
if (event.which == 1) i();
else if (event.which == 3) {
Feed = true;
setTimeout(F, imlost);
}
}
// Feed macro with right mouse btn
function mouseup(event) {
if (event.which == 3) {
Feed = false;
}
}
// Disable context menu
function discm(e) {
if (!$('input').is(':focus')) e.preventDefault();
}
// Feed Macro With Q
function F() {
if (Feed) {
window.onkeydown({keyCode: 87});
window.onkeyup({keyCode: 87});
setTimeout(F, imlost);
}
}
function i() {
$("body").trigger($.Event("keydown", { keyCode: 32}));
$("body").trigger($.Event("keyup", { keyCode: 32}));
}
下面的代码被编程为监听键盘事件,但我想将其更改为监听鼠标按钮。例如,我不想用 Q 快速进给,而是想用鼠标右键,而不是用 space 拆分,我想用鼠标左键,有人能帮忙吗?
// ==UserScript==
// @name Best Tricksplit, Doublesplit, and Feeding Macros + Auto Settings + Triplesplit Macro
// @namespace http://tampermonkey.net/
// @version 0.9
// @description Sets show mass and dark theme to true, provides a tricksplit with E or 4, triplesplit with 3, doublesplit with D or 2, faster feeding with Q, and split with 1
// @author Jack Burch + Tom Burris
// @match http://abs0rb.me/*
// @match http://agar.io/*
// @match http://agarabi.com/*
// @match http://agarly.com/*
// @match http://en.agar.bio/*
// @match http://agar.pro/*
// @match http://agar.biz/*
// @grant none
// @run-at document-end
// ==/UserScript==
window.addEventListener('keydown', keydown);
window.addEventListener('keyup', keyup);
var Feed = false;
var Dingus = false;
var imlost = 25;
load();
function keydown(event) {
if (event.keyCode == 81) {
Feed = true;
setTimeout(F, imlost);
} // Tricksplit
if (event.keyCode == 16) {
i();
setTimeout(i, imlost);
setTimeout(i, imlost*2);
setTimeout(i, imlost*3);
} // Doublesplit
if (event.keyCode == 18 ) {
i();
setTimeout(i, imlost);
}// Split
if (event.keyCode == 32) {
i();
}
} // When Player left Q, It Stop Feeding fast
function keyup(event) {
if (event.keyCode == 81) {
Feed = false;
}
if (event.keyCode == 79) {
Dingus = false;
}
}
// Feed Macro With Q
function F() {
if (Feed) {
window.onkeydown({keyCode: 87});
window.onkeyup({keyCode: 87});
setTimeout(F, imlost);
}
}
function i() {
$("body").trigger($.Event("keydown", { keyCode: 32}));
$("body").trigger($.Event("keyup", { keyCode: 32}));
}
经过我朋友的一些研究和帮助,我发现代码应该更改为如下所示
// ==UserScript==
// @name saqar
// @namespace http://tampermonkey.net/
// @version 0.9
// @description Sets show mass and dark theme to true, provides a tricksplit with E or 4, triplesplit with 3, doublesplit with D or 2, faster feeding with Q, and split with 1
// @author Jack Burch + Tom Burris
// @match http://abs0rb.me/*
// @match http://3rb.be/*
// @match http://agar.io/*
// @match http://agarabi.com/*
// @match http://cell.sh/*
// @match http://agarly.com/*
// @match http://en.agar.bio/*
// @match http://agar.pro/*
// @match http://agar.biz/*
// @grant none
// @run-at document-end
// ==/UserScript==
window.addEventListener('keydown', keydown);
window.addEventListener('keyup', keyup);
window.addEventListener('mousedown', mousedown);
window.addEventListener('mouseup', mouseup);
window.addEventListener('contextmenu', discm);
var Feed = false;
var Dingus = false;
var imlost = 25;
load();
function keydown(event) {
if (event.keyCode == 81) {
Feed = true;
setTimeout(F, imlost);
} // Tricksplit
if (event.keyCode == 16) {
i();
setTimeout(i, imlost);
setTimeout(i, imlost*2);
setTimeout(i, imlost*3);
setTimeout(i, imlost*4);
} // Doublesplit
if (event.keyCode == 18 ) {
i();
setTimeout(i, imlost);
}// Split
if (event.keyCode == 32) {
i();
}
} // When Player left Q, It Stop Feeding fast
function keyup(event) {
if (event.keyCode == 81) {
Feed = false;
}
if (event.keyCode == 79) {
Dingus = false;
}
}
// Split with left mouse btn
function mousedown(event) {
if (event.which == 1) i();
else if (event.which == 3) {
Feed = true;
setTimeout(F, imlost);
}
}
// Feed macro with right mouse btn
function mouseup(event) {
if (event.which == 3) {
Feed = false;
}
}
// Disable context menu
function discm(e) {
if (!$('input').is(':focus')) e.preventDefault();
}
// Feed Macro With Q
function F() {
if (Feed) {
window.onkeydown({keyCode: 87});
window.onkeyup({keyCode: 87});
setTimeout(F, imlost);
}
}
function i() {
$("body").trigger($.Event("keydown", { keyCode: 32}));
$("body").trigger($.Event("keyup", { keyCode: 32}));
}