Gats.io right click for spacebar

This script allows you to use your right click for the abilities you usually use with spacebar. However it wont work for shield yet (working on it).

当前为 2022-09-15 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Gats.io right click for spacebar
// @version      2.0.6.11
// @description  This script allows you to use your right click for the abilities you usually use with spacebar. However it wont work for shield yet (working on it).
// @author       Rayan223
// @match        https://gats.io
// @icon         none
// @grant        none
// @license MIT
// @namespace https://greasyfork.org/users/825882
// ==/UserScript==

let canvas = document.getElementById('canvas');



var rightClick = 0;
var unRightClick = 0;

var loaded = 0;
document.addEventListener('DOMContentLoaded', function(event) {
    loaded = 1;
});

document.addEventListener('mousedown', function(event){
    canvas.width = "726";
    console.log("clic123");
    if(event.which== 2){
        console.log("clic");
    }
});

document.addEventListener('mouseup', function(event){
    console.log("unclic123");
    if(event.which== 2){
        console.log("unclic");
    }
});

document.body.onmousedown = function(e) {
    if (e.button == 2) {
        ++rightClick;
        click();
        console.log("clic");
    }
};

document.body.onmouseup = function(e) {
    if (e.button == 2) {
        --rightClick;
        ++unRightClick;
        click();
        console.log("unclic");
    }
};

function click() {
    if(loaded == 0){
        return;
    }
    if(rightClick == 1){
        RF.list[0].socket.send('k,5,1');
    }
    if (unRightClick == 1){
        RF.list[0].socket.send('k,5,0');
        --unRightClick;
    }
    
}
    
//window.oncontextmenu = function ()
//{
//    dash();
//    setTimeout(afterdash,50);
//    return false;
//}

//function dash(){
//    RF.list[0].socket.send('k,5,1');
//}

//function afterdash(){
//    RF.list[0].socket.send('k,5,0');
//}