Glar Autohat

An auto interval hat switcher for glar.io

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Glar Autohat
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  An auto interval hat switcher for glar.io
// @author       flancast90
// @match        *://glar.io/*
// @grant        none
// ==/UserScript==


var pressed = false
var i = 0
var hats;

if (window.location.href == 'http://glar.io/') {
    window.location.href = "http://glar.io/?game=eyJpcCI6InBob2VuaXguZ2xhci5pbyIsInBvcnQiOjUwMDAsInNzbCI6ZmFsc2UsImlkIjoxfQ"
}else {
    if (window.location.href == "http://glar.io/?game=eyJpcCI6InBob2VuaXguZ2xhci5pbyIsInBvcnQiOjUwMDAsInNzbCI6ZmFsc2UsImlkIjoxfQ") {
        document.addEventListener("keydown", function(e) {
            if (e.keyCode == 81) {
                if (pressed == false) {
                    document.getElementById("ui-hat-list-container").style.left = "-1000px";
                    hats = setInterval(change_hat, 500);
                    pressed = true;
                } else {
                    document.getElementById("ui-hat-list-container").style.left = "50%";
                    clearInterval(hats);
                    pressed = false;
                }
            }
        });

        function change_hat() {
            var len = document.getElementsByClassName('ui-hat-list-item').length;
            if (i < len) {
                document.getElementsByClassName('ui-hat-list-item')[i].click();
                i++;
            } else {
                i = 0;
            }
        }
    }else {
        document.write("Access Error: Hack Banned Except for on Extreme Server.")
    }
}