AutoHat [Fix chat]

fix by super_kanal (glar.io, glario, auto hat)

// ==UserScript==
// @name         AutoHat [Fix chat]
// @namespace    -
// @version      0.2
// @description  fix by super_kanal (glar.io, glario, auto hat)
// @author       Скрипт архитектора он люит маленькие члены
// @match        *://glar.io/*
// @grant        none
// ==/UserScript==

document.addEventListener('keydown', function(e) {
    if (e.keyCode === 81) {
        var inputElement = document.querySelector('.d631d361bc3 input[type="text"]');
        if (inputElement && inputElement.offsetParent !== null) {
            return;
        }
        var hatListContent = document.querySelector('.ui-hat-list-content');
        if (hatListContent) {
            hatListContent.style.display = 'none';
            setTimeout(() => {
                selectHat();
                requestAnimationFrame(() => {
                    hatListContent.style.display = '';
                });
            }, 0);
        } else {
            selectHat();
        }
    }
});

function selectHat() {
    var hats = document.querySelectorAll('.ui-hat-list-item');
    var chesshatFound = false;
    hats.forEach(function(hat) {
        var hatImageUrl = hat.querySelector('img').src;
        if (hatImageUrl === 'https://assets.glar.io/uploads/entity_asset/image/104/chesshat.png') {
            chesshatFound = true;
            hat.click();
            setTimeout(closeHatList, 0);
        } else if (hatImageUrl === 'https://assets.glar.io/uploads/entity_asset/image/57/tankhat.png') {
            hat.click();
            setTimeout(closeHatList, 0);
        }
    });
    if (!chesshatFound) {
        hats.forEach(function(hat) {
            var hatImageUrl = hat.querySelector('img').src;
            if (hatImageUrl === 'https://assets.glar.io/uploads/entity_asset/image/102/rabbit-hat.png') {
                hat.click();
                setTimeout(closeHatList, 0);
            }
        });
    }
}

function closeHatList() {
    var closeButton = document.getElementById('ui-hat-close-button');
    if (closeButton) {
        closeButton.click();
    }
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址