Gats.io - Multiboxing Script

Multiboxing script for Gats.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Gats.io - Multiboxing Script
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Multiboxing script for Gats.
// @author       nitrogem35
// @match        https://gats.io
// ==/UserScript==
 
(function() {
    'use strict';
    //note for the dev: fix your game lmfao
    var channel = new BroadcastChannel('multibox');
    var main = true;
 
    channel.postMessage('.');
 
    channel.onmessage = function(ev) {
        if(ev.data == '.') {
            main = false;
            document.addEventListener('mousemove', mousemove);
 
            function mousemove(event) {
                channel.postMessage(`m,${event.clientX},${event.clientY}`);
            }
 
            document.addEventListener('mousedown', mousedown);
 
            function mousedown(event) {
                channel.postMessage(`k,${event.clientX},${event.clientY},0`);
            }
 
            document.addEventListener('mouseup', mouseup);
 
            function mouseup(event) {
                channel.postMessage(`k,${event.clientX},${event.clientY},1`);
            }
 
            document.addEventListener('keydown', keydown);
 
            function keydown(event) {
                channel.postMessage(`a,${event.keyCode},1`);
            }
 
            document.addEventListener('keyup', keyup);
 
            function keyup(event) {
                channel.postMessage(`a,${event.keyCode},0`);
            }
        }
        else if(main) {
            if(ev.data.startsWith("m")) {
                var packet = ev.data.split(",");
                packet.shift();
                var mouseMoveEvent = document.createEvent("MouseEvents");
                mouseMoveEvent.initMouseEvent(
                    "mousemove",true,false,unsafeWindow,1,50,50,packet[0],packet[1],false,false,false,false,0,null
                );
                canvas.dispatchEvent(mouseMoveEvent);
            };
 
            if(ev.data.startsWith("k")) {
                var packet = ev.data.split(",")
                packet.shift();
                var mouseClickEvent = document.createEvent("MouseEvents");
                var z = ["mousedown", "mouseup"]
                var type = z[parseInt(packet[2])]
                mouseClickEvent.initMouseEvent(type,true,false,unsafeWindow,1,50,50,packet[0],packet[1],false,false,false,false,0,null);
                canvas.dispatchEvent(mouseClickEvent)
            };
 
            if(ev.data.startsWith("a")) {
                var packet = ev.data.split(",");
                packet.shift();
                if(packet[1] == "1") {
                    var evt = new KeyboardEvent('keydown', {'keyCode': packet[0]});
                }
                else {
                    var evt = new KeyboardEvent('keyup', {'keyCode': packet[0]});
                };
                document.dispatchEvent(evt);
            };
        };
    }
 
})();