agarpowers hold to drop

try to take over the world!!

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         agarpowers hold to drop
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  try to take over the world!!
// @author       kidmaletteo
// @license      MIT
// @match        http://62.68.75.115:90/
// @grant        none
// ==/UserScript==

$(function () {
    const holdDelay = 500, // ms delay to start dropping after pressing
          dropDelay = 100 // ms delay between drops

    let keys = {};
    $(document).on("keydown", (e) => {
        // if (e.keyCode != $('#pellet').text().charCodeAt(0)) return;
        if (e.keyCode in keys) return;
        keys[e.keyCode] = setTimeout(() => {
            drop(e.keyCode);
        }, holdDelay);
    }).on("keyup", (e) => {
        clearTimeout(keys[e.keyCode]);
        delete keys[e.keyCode];
    });
    const drop = key => {
        if (keys[key] == null) return;
        window.onkeydown({ keyCode: key });
        window.onkeyup({ keyCode: key });
        setTimeout(drop, dropDelay, key);
    }
});