ueuyegf

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

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

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

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

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

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

})();