☰

craft quick (press left mouse to use)

Giữ Chuột Phải vào nút Chế tạo để tự động click chuột trái liên tục, nhả ra để dừng.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        craft quick (press left mouse to use)
// @namespace    http://tampermonkey.net/
// @version      5.0
// @description  Giữ Chuột Phải vào nút Chế tạo để tự động click chuột trái liên tục, nhả ra để dừng.
// @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
    const CLICK_SPEED = 40;

    // Liên tục cập nhật tọa độ của con trỏ chuột
    window.addEventListener('mousemove', (e) => {
        mouseX = e.clientX;
        mouseY = e.clientY;
    });

    // Khi nhấn giữ CHUỘT PHẢI (button = 2)
    window.addEventListener('mousedown', (e) => {
        if (e.button === 2 && !clickInterval) {
            
            clickInterval = setInterval(() => {
                // Xác định phần tử UI 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 PHẢI để chế đồ
                    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 });
                    const clickEvent = new MouseEvent('click', { 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) => {
        if (e.button === 2 && clickInterval) {
            clearInterval(clickInterval);
            clickInterval = null;
        }
    });

    // Chặn menu chuột trái (Context Menu) 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
    window.addEventListener('blur', () => {
        if (clickInterval) {
            clearInterval(clickInterval);
            clickInterval = null;
        }
    });
})();