agarpowers hold to drop

try to take over the world!!

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 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);
    }
});