ZType Bot

Bot for typing game ZType

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         ZType Bot
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Bot for typing game ZType
// @author       Deltaspace
// @match        https://zty.pe/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zty.pe
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    window.addEventListener('keydown', function(e) {
        if (e.key !== ' ') {
            return;
        }
        if (!window.ig.game.currentTarget) {
            var nearestDistance = -1;
            var nearestTargetKey = null;
            Object.keys(window.ig.game.targets).forEach(function(key) {
                var potentialTargets = window.ig.game.targets[key];
                for (var i = 0; i < potentialTargets.length; i++) {
                    var distance = window.ig.game.player.distanceTo(potentialTargets[i]);
                    if (distance < nearestDistance || !nearestTargetKey) {
                        nearestDistance = distance;
                        nearestTargetKey = key;
                    }
                }
            });
            window.ig.game.bufferLetter(nearestTargetKey);
        } else {
            var currentTargetKey = window.ig.game.currentTarget.remainingWord.charAt(0);
            var letter = window.ig.game.translateUmlaut(currentTargetKey.toLowerCase());
            window.ig.game.bufferLetter(letter);
        }
    });
})();