craft quick (press left mouse to use)

Giữ Chuột Trái để tự động click liên tục (bắn tự động/chế đồ nhanh), nhả ra để dừng. Không ảnh hưởng đến Chuột Phải (Nhắm).

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         craft quick (press left mouse to use)
// @namespace    http://tampermonkey.net/
// @version      5.1
// @description  Giữ Chuột Trái để tự động click liên tục (bắn tự động/chế đồ nhanh), nhả ra để dừng. Không ảnh hưởng đến Chuột Phải (Nhắm).
// @author       Gemini
// @match        *://minefun.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let mouseX = 0;
    let mouseY = 0;
    let clickInterval = null;
    
    // Tốc độ click: 40ms = 25 click/giây (bạn có thể chỉnh thấp hơn nếu game bị lag)
    const CLICK_SPEED = 40;

    // Liên tục cập nhật tọa độ của con trỏ chuột
    window.addEventListener('mousemove', (e) => {
        // Chỉ cập nhật nếu là thao tác thật từ chuột
        if(e.isTrusted) {
            mouseX = e.clientX;
            mouseY = e.clientY;
        }
    });

    // Khi nhấn giữ CHUỘT TRÁI (button = 0)
    window.addEventListener('mousedown', (e) => {
        // e.isTrusted đảm bảo đây là click thật từ người chơi, không phải click giả lập từ code
        if (e.button === 0 && e.isTrusted && !clickInterval) {
            
            clickInterval = setInterval(() => {
                // Xác định phần tử UI hoặc game nằm ngay dưới con trỏ chuột
                const element = document.elementFromPoint(mouseX, mouseY);
                
                if (element) {
                    // Giả lập hành động click CHUỘT TRÁI
                    const mouseDown = new MouseEvent('mousedown', { bubbles: true, cancelable: true, view: window, button: 0 });
                    const mouseUp = new MouseEvent('mouseup', { bubbles: true, cancelable: true, view: window, button: 0 });
                    
                    element.dispatchEvent(mouseDown);
                    element.dispatchEvent(mouseUp);
                    element.click();
                }
            }, CLICK_SPEED);
        }
    });

    // Khi thả Chuột Trái ra thì lập tức dừng click
    window.addEventListener('mouseup', (e) => {
        // Phải kiểm tra e.isTrusted để code không tự tắt bởi các click giả lập
        if (e.button === 0 && e.isTrusted && clickInterval) {
            clearInterval(clickInterval);
            clickInterval = null;
        }
    });

    // (Tuỳ chọn) Chặn menu chuột phải của trình duyệt để màn hình game không bị vướng
    window.addEventListener('contextmenu', (e) => {
        e.preventDefault();
    });

    // Tự động dừng nếu bạn tab ra ngoài màn hình để tránh kẹt click
    window.addEventListener('blur', () => {
        if (clickInterval) {
            clearInterval(clickInterval);
            clickInterval = null;
        }
    });
})();