craft quick (smart right click)

Trong UI: Giữ Chuột Phải vào nút Chế tạo để chế đồ nhanh, Chuột Trái lấy đồ bình thường. Trong Game: Bắn tự động và nhắm bình thường.

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

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

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

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         craft quick (smart right click)
// @namespace    http://tampermonkey.net/
// @version      6.0
// @description  Trong UI: Giữ Chuột Phải vào nút Chế tạo để chế đồ nhanh, Chuột Trái lấy đồ bình thường. Trong Game: Bắn tự động và nhắm bình thườ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 độ chuột khi đang ở trong Menu
    window.addEventListener('mousemove', (e) => {
        if(e.isTrusted) {
            mouseX = e.clientX;
            mouseY = e.clientY;
        }
    });

    // KHI BẤM CHUỘT XUỐNG
    window.addEventListener('mousedown', (e) => {
        // NẾU ĐANG TRONG TRẬN (Chuột bị ẩn): Bỏ qua hoàn toàn, nhường quyền cho game để bắn/nhắm.
        if (document.pointerLockElement) {
            return;
        }

        // CHỈ KÍCH HOẠT KHI GIỮ CHUỘT PHẢI (button === 2) TRONG MENU
        if (e.button === 2 && e.isTrusted && !clickInterval) {
            const element = document.elementFromPoint(mouseX, mouseY);
            
            // Nếu click nhầm ra ngoài nền 3D thì bỏ qua
            if (element && element.tagName.toLowerCase() === 'canvas') {
                return;
            }
            
            // Bắt đầu chế độ Auto-Click (Nhấp chuột trái liên tục vào vị trí đang chỉ)
            clickInterval = setInterval(() => {
                const currentElement = document.elementFromPoint(mouseX, mouseY);
                
                if (currentElement && currentElement.tagName.toLowerCase() !== 'canvas') {
                    // Giả lập phím bấm Chuột Trái (button: 0) để 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 });
                    
                    currentElement.dispatchEvent(mouseDown);
                    currentElement.dispatchEvent(mouseUp);
                    currentElement.dispatchEvent(clickEvent);
                }
            }, CLICK_SPEED);
        }
    });

    // KHI NHẢ CHUỘT PHẢI RA
    window.addEventListener('mouseup', (e) => {
        if (e.button === 2 && e.isTrusted && clickInterval) {
            clearInterval(clickInterval);
            clickInterval = null;
        }
    });

    // Chặn menu chuột phải của trình duyệt khi ở trong túi đồ để không bị hiện menu rác che màn hình
    window.addEventListener('contextmenu', (e) => {
        if (!document.pointerLockElement) {
            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;
        }
    });
})();