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).

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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;
        }
    });
})();