ueuyegf

1 click = 2 clicks, with UI and proper CPS control

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ueuyegf
// @namespace    https://greasyfork.org/users/yourname
// @version      1.1
// @description  1 click = 2 clicks, with UI and proper CPS control
// @match        *://*/*
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let enabled = false;
    let toggleKey = "KeyG"; // Press G to toggle
    let menuVisible = true;

    // Cooldown to prevent 500 CPS spam
    let lastClickTime = 0;
    const cooldown = 50; // ms — prevents multiple duplicates per real click

    // --- UI CREATION ---
    const ui = document.createElement("div");
    ui.style = `
        position: fixed;
        top: 20px;
        left: 20px;
        width: 180px;
        padding: 12px;
        background: rgba(20,20,20,0.85);
        color: white;
        font-family: sans-serif;
        border-radius: 10px;
        z-index: 999999;
        backdrop-filter: blur(6px);
        border: 1px solid #444;
        user-select: none;
        transition: opacity 0.2s ease;
    `;
    ui.innerHTML = `
        <div style="font-size:16px; margin-bottom:8px; font-weight:600;">
            DoubleClick UI
        </div>

        <div style="margin-bottom:6px;">
            <b>Status:</b> <span id="dc-status" style="color:#f55;">OFF</span>
        </div>

        <div style="margin-bottom:6px;">
            <b>Toggle Key:</b> G
        </div>

        <div style="margin-bottom:6px;">
            <b>Hide Menu:</b> ArrowDown
        </div>

        <button id="dc-toggle" style="
            width:100%;
            padding:6px;
            background:#333;
            color:white;
            border:1px solid #555;
            border-radius:6px;
            cursor:pointer;
        ">Enable</button>
    `;
    document.body.appendChild(ui);

    const statusEl = ui.querySelector("#dc-status");
    const toggleBtn = ui.querySelector("#dc-toggle");

    // --- DRAGGABLE UI ---
    let dragging = false, offsetX = 0, offsetY = 0;

    ui.addEventListener("mousedown", e => {
        dragging = true;
        offsetX = e.clientX - ui.offsetLeft;
        offsetY = e.clientY - ui.offsetTop;
    });

    document.addEventListener("mousemove", e => {
        if (!dragging) return;
        ui.style.left = (e.clientX - offsetX) + "px";
        ui.style.top = (e.clientY - offsetY) + "px";
    });

    document.addEventListener("mouseup", () => dragging = false);

    // --- TOGGLE LOGIC ---
    function updateUI() {
        if (enabled) {
            statusEl.textContent = "ON";
            statusEl.style.color = "#5f5";
            toggleBtn.textContent = "Disable";
        } else {
            statusEl.textContent = "OFF";
            statusEl.style.color = "#f55";
            toggleBtn.textContent = "Enable";
        }
    }

    toggleBtn.onclick = () => {
        enabled = !enabled;
        updateUI();
    };

    document.addEventListener("keydown", e => {
        if (e.code === toggleKey) {
            enabled = !enabled;
            updateUI();
        }

        // ArrowDown hides/shows menu
        if (e.code === "ArrowDown") {
            menuVisible = !menuVisible;
            ui.style.opacity = menuVisible ? "1" : "0";
            ui.style.pointerEvents = menuVisible ? "auto" : "none";
        }
    });

    // --- DOUBLE CLICK LOGIC ---
    window.addEventListener("click", function(e) {
        if (!enabled) return;

        const now = performance.now();

        // Prevent multiple duplicates from bubbling
        if (now - lastClickTime < cooldown) return;
        lastClickTime = now;

        // Fire 1 extra synthetic click
        const c1 = new MouseEvent("click", {
            bubbles: true,
            cancelable: true,
            clientX: e.clientX,
            clientY: e.clientY
        });

        e.target.dispatchEvent(c1);
    }, true);

})();