Glar Autohat

An auto interval hat switcher for glar.io

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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.")
    }
}