Main Menu - Auto Clicker & Speedhack Controller

Menu chính điều khiển auto clicker và speedhack

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Main Menu - Auto Clicker & Speedhack Controller
// @namespace    http://tampermonkey.net/
// @version      2.2
// @license      MIT
// @description  Menu chính điều khiển auto clicker và speedhack
// @author       Admin
// @icon         https://i.postimg.cc/3wJFzXWv/resized-image.jpg
// @match        *://*/*
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_xmlhttpRequest
// @grant        GM_openInTab
// @grant        GM_deleteValue
// @grant        GM_listValues
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';
    
    if (document.querySelector('.main-menu-fab')) return;
    
    let isDragging = false;
    let dragStarted = false;
    let dragOffsetX = 0, dragOffsetY = 0;
    let loaderScriptInjected = false;
    let speedhackScriptInjected = false;
    
    // Trang thai toggle
    let toggleStates = {
        autoClicker: GM_getValue('toggle_autoClicker', false),
        speedhack: GM_getValue('toggle_speedhack', false),
        coming2: GM_getValue('toggle_coming2', false),
        coming3: GM_getValue('toggle_coming3', false)
    };
    
    // ========== CSS ==========
    GM_addStyle(`
        .main-menu-fab {
            position: fixed;
            bottom: 80px;
            right: 20px;
            width: 55px;
            height: 55px;
            border-radius: 50%;
            background: #00adb5;
            box-shadow: 0 4px 15px rgba(0,0,0,0.3);
            z-index: 999999;
            cursor: grab;
            overflow: hidden;
            border: 2px solid white;
            transition: transform 0.1s;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .main-menu-fab img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            object-fit: cover;
            pointer-events: none;
        }
        .main-menu-fab:active {
            cursor: grabbing;
            transform: scale(0.95);
        }
        .main-menu-panel {
            position: fixed;
            bottom: 150px;
            right: 20px;
            width: 280px;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
            border-radius: 16px;
            border: 1px solid #667eea;
            color: white;
            font-family: 'Segoe UI', Arial, sans-serif;
            font-size: 14px;
            z-index: 999998;
            box-shadow: 0 8px 25px rgba(0,0,0,0.5);
            display: none;
            backdrop-filter: blur(5px);
        }
        .main-menu-panel.show { display: block; }
        .main-menu-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 15px;
            background: rgba(102,126,234,0.2);
            border-bottom: 1px solid #667eea;
            border-radius: 16px 16px 0 0;
            cursor: grab;
        }
        .main-menu-header:active { cursor: grabbing; }
        .main-menu-title { font-weight: bold; color: #667eea; font-size: 14px; }
        .main-menu-close {
            background: #ff4757;
            border: none;
            color: white;
            width: 26px;
            height: 26px;
            border-radius: 50%;
            cursor: pointer;
            font-size: 14px;
        }
        .main-menu-content { padding: 12px; }
        .menu-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px;
            margin: 8px 0;
            background: #0f0f1a;
            border-radius: 10px;
        }
        .menu-item-left { display: flex; flex-direction: column; gap: 4px; }
        .menu-item-title { font-weight: bold; font-size: 14px; }
        .menu-item-desc { font-size: 11px; color: #aaa; }
        .toggle-switch {
            position: relative;
            width: 50px;
            height: 24px;
            background-color: #2d2d44;
            border-radius: 12px;
            cursor: pointer;
            transition: all 0.3s;
        }
        .toggle-switch.active { background-color: #00adb5; }
        .toggle-slider {
            position: absolute;
            top: 2px;
            left: 2px;
            width: 20px;
            height: 20px;
            background-color: white;
            border-radius: 50%;
            transition: all 0.3s;
        }
        .toggle-switch.active .toggle-slider { left: 28px; }
        @media (max-width: 768px) {
            .main-menu-panel { width: 260px; right: 10px; bottom: 130px; }
            .main-menu-fab { bottom: 70px; right: 10px; width: 50px; height: 50px; }
        }
    `);
    
    // ========== TAO MENU ==========
    const fab = document.createElement('div');
    fab.className = 'main-menu-fab';
    
    const avatarImg = document.createElement('img');
    avatarImg.src = 'https://i.postimg.cc/3wJFzXWv/resized-image.jpg';
    avatarImg.alt = 'Menu';
    fab.appendChild(avatarImg);
    document.body.appendChild(fab);
    
    const panel = document.createElement('div');
    panel.className = 'main-menu-panel';
    panel.innerHTML = `
        <div class="main-menu-header" id="mainMenuHeader">
            <span class="main-menu-title">Control Panel</span>
            <button class="main-menu-close" id="closeMenuBtn">✖</button>
        </div>
        <div class="main-menu-content">
            <div class="menu-item">
                <div class="menu-item-left">
                    <span class="menu-item-title">🎮 Auto Clicker</span>
                    <span class="menu-item-desc">Auto click theo tọa độ</span>
                </div>
                <div class="toggle-switch" id="toggleAutoClicker">
                    <div class="toggle-slider"></div>
                </div>
            </div>
            <div class="menu-item">
                <div class="menu-item-left">
                    <span class="menu-item-title">⚡ Speedhack</span>
                    <span class="menu-item-desc">Tăng tốc game/video</span>
                </div>
                <div class="toggle-switch" id="toggleSpeedhack">
                    <div class="toggle-slider"></div>
                </div>
            </div>
            <div class="menu-item">
                <div class="menu-item-left">
                    <span class="menu-item-title">📦 Tính năng 2</span>
                    <span class="menu-item-desc">Coming soon</span>
                </div>
                <div class="toggle-switch" id="toggleComing2">
                    <div class="toggle-slider"></div>
                </div>
            </div>
            <div class="menu-item">
                <div class="menu-item-left">
                    <span class="menu-item-title">📦 Tính năng 3</span>
                    <span class="menu-item-desc">Coming soon</span>
                </div>
                <div class="toggle-switch" id="toggleComing3">
                    <div class="toggle-slider"></div>
                </div>
            </div>
        </div>
    `;
    document.body.appendChild(panel);
    
    // ========== CAP NHAT UI TOGGLE ==========
    function updateToggleUI() {
        const toggleAuto = document.getElementById('toggleAutoClicker');
        const toggleSpeed = document.getElementById('toggleSpeedhack');
        const toggle2 = document.getElementById('toggleComing2');
        const toggle3 = document.getElementById('toggleComing3');
        
        if (toggleAuto) {
            if (toggleStates.autoClicker) toggleAuto.classList.add('active');
            else toggleAuto.classList.remove('active');
        }
        if (toggleSpeed) {
            if (toggleStates.speedhack) toggleSpeed.classList.add('active');
            else toggleSpeed.classList.remove('active');
        }
        if (toggle2) {
            if (toggleStates.coming2) toggle2.classList.add('active');
            else toggle2.classList.remove('active');
        }
        if (toggle3) {
            if (toggleStates.coming3) toggle3.classList.add('active');
            else toggle3.classList.remove('active');
        }
    }
    
    // ========== LOAD AUTO CLICKER SCRIPT ==========
    function loadAutoClickerScript() {
        if (loaderScriptInjected) {
            console.log('Auto Clicker da duoc tai');
            return;
        }
        
        console.log('Dang tai Auto Clicker script tu GitHub...');
        
        const script = document.createElement('script');
        script.textContent = `
            (function() {
                const sourceUrl = "https://raw.githubusercontent.com/Minhbeo8/autoclickGUI/refs/heads/main/autoclick.js";
                if (window._autoClickerLoaded) return;
                window._autoClickerLoaded = true;
                
                function loadScript(url, callback) {
                    var xhr = new XMLHttpRequest();
                    xhr.open('GET', url + '?t=' + Date.now(), true);
                    xhr.onload = function() {
                        if (xhr.status === 200 && xhr.responseText) {
                            try {
                                new Function(xhr.responseText)();
                                if (callback) callback();
                            } catch(e) { console.error('Loi execute:', e); }
                        } else {
                            console.error('Khong the tai script:', xhr.status);
                        }
                    };
                    xhr.onerror = function() { console.error('Loi ket noi'); };
                    xhr.send();
                }
                
                loadScript(sourceUrl);
                console.log('Auto Clicker Loader da duoc khoi tao');
            })();
        `;
        document.head.appendChild(script);
        loaderScriptInjected = true;
        
        const noti = document.createElement('div');
        noti.textContent = 'Auto Clicker da duoc kich hoat!';
        noti.style.cssText = 'position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:#00adb5; color:white; padding:8px 16px; border-radius:8px; z-index:1000000; font-size:12px;';
        document.body.appendChild(noti);
        setTimeout(() => noti.remove(), 2000);
    }
    
    // ========== LOAD SPEEDHACK SCRIPT ==========
    function loadSpeedhackScript() {
        if (speedhackScriptInjected) {
            console.log('Speedhack da duoc tai');
            return;
        }
        
        console.log('Dang tai Speedhack script tu GreasyFork...');
        
        const script = document.createElement('script');
        script.textContent = `
            (function() {
                const sourceUrl = "https://update.greasyfork.org/scripts/543798/Universal%20HTML5%20Speed%20Hack.user.js";
                if (window._speedhackLoaded) return;
                window._speedhackLoaded = true;
                
                function loadScript(url, callback) {
                    var xhr = new XMLHttpRequest();
                    xhr.open('GET', url + '?t=' + Date.now(), true);
                    xhr.onload = function() {
                        if (xhr.status === 200 && xhr.responseText) {
                            try {
                                new Function(xhr.responseText)();
                                if (callback) callback();
                            } catch(e) { console.error('Loi execute:', e); }
                        } else {
                            console.error('Khong the tai script:', xhr.status);
                        }
                    };
                    xhr.onerror = function() { console.error('Loi ket noi'); };
                    xhr.send();
                }
                
                loadScript(sourceUrl);
                console.log('Speedhack Loader da duoc khoi tao');
            })();
        `;
        document.head.appendChild(script);
        speedhackScriptInjected = true;
        
        const noti = document.createElement('div');
        noti.textContent = 'Speedhack da duoc kich hoat! Nhan "L" de an/hien menu.';
        noti.style.cssText = 'position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:#00adb5; color:white; padding:8px 16px; border-radius:8px; z-index:1000000; font-size:12px;';
        document.body.appendChild(noti);
        setTimeout(() => noti.remove(), 3000);
    }
    
    // ========== UNLOAD AUTO CLICKER SCRIPT ==========
    function unloadAutoClickerScript() {
        console.log('Dang tat Auto Clicker...');
        
        const elementsToRemove = [
            '.autoClick-fab',
            '.autoClick-panel',
            '.coord-preview'
        ];
        
        elementsToRemove.forEach(sel => {
            document.querySelectorAll(sel).forEach(el => el.remove());
        });
        
        document.querySelectorAll('style').forEach(style => {
            if (style.textContent.includes('autoClick-fab') || 
                style.textContent.includes('autoClick-panel') ||
                style.textContent.includes('coord-preview')) {
                if (!style.textContent.includes('main-menu')) {
                    style.remove();
                }
            }
        });
        
        delete window._autoClickerLoaded;
        delete window.autoClickerInitialized;
        
        loaderScriptInjected = false;
        
        const noti = document.createElement('div');
        noti.textContent = 'Auto Clicker da duoc tat!';
        noti.style.cssText = 'position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:#ff4757; color:white; padding:8px 16px; border-radius:8px; z-index:1000000; font-size:12px;';
        document.body.appendChild(noti);
        setTimeout(() => noti.remove(), 2000);
    }
    
    // ========== UNLOAD SPEEDHACK SCRIPT ==========
    function unloadSpeedhackScript() {
        console.log('Dang tat Speedhack...');
        
        const elementsToRemove = [
            '#speedhack-ui'
        ];
        
        elementsToRemove.forEach(sel => {
            const el = document.querySelector(sel);
            if (el) el.remove();
        });
        
        delete window._speedhackLoaded;
        
        speedhackScriptInjected = false;
        
        const noti = document.createElement('div');
        noti.textContent = 'Speedhack da duoc tat! Refresh trang de xoa hoan toan.';
        noti.style.cssText = 'position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:#ff4757; color:white; padding:8px 16px; border-radius:8px; z-index:1000000; font-size:12px;';
        document.body.appendChild(noti);
        setTimeout(() => noti.remove(), 3000);
    }
    
    // ========== XU LY TOGGLE ==========
    function handleToggle(item, isOn) {
        switch(item) {
            case 'autoClicker':
                if (isOn) {
                    loadAutoClickerScript();
                } else {
                    unloadAutoClickerScript();
                }
                break;
            case 'speedhack':
                if (isOn) {
                    loadSpeedhackScript();
                } else {
                    unloadSpeedhackScript();
                }
                break;
            case 'coming2':
            case 'coming3':
                if (isOn) {
                    alert('Tinh nang dang duoc phat trien. Se cap nhat trong thoi gian toi!');
                    setTimeout(() => {
                        if (item === 'coming2') toggleStates.coming2 = false;
                        if (item === 'coming3') toggleStates.coming3 = false;
                        GM_setValue(`toggle_${item}`, false);
                        updateToggleUI();
                    }, 100);
                }
                break;
        }
    }
    
    // ========== KEO THA FAB ==========
    fab.addEventListener('mousedown', (e) => {
        if (e.target === fab || fab.contains(e.target)) {
            isDragging = true;
            dragStarted = false;
            dragOffsetX = e.clientX - fab.offsetLeft;
            dragOffsetY = e.clientY - fab.offsetTop;
            fab.style.cursor = 'grabbing';
            fab.style.transition = 'none';
            e.preventDefault();
            e.stopPropagation();
        }
    });
    
    fab.addEventListener('touchstart', (e) => {
        const touch = e.touches[0];
        isDragging = true;
        dragStarted = false;
        dragOffsetX = touch.clientX - fab.offsetLeft;
        dragOffsetY = touch.clientY - fab.offsetTop;
        fab.style.cursor = 'grabbing';
        fab.style.transition = 'none';
        e.preventDefault();
        e.stopPropagation();
    });
    
    window.addEventListener('mousemove', (e) => {
        if (isDragging) {
            dragStarted = true;
            let left = e.clientX - dragOffsetX;
            let top = e.clientY - dragOffsetY;
            left = Math.max(0, Math.min(window.innerWidth - fab.offsetWidth, left));
            top = Math.max(0, Math.min(window.innerHeight - fab.offsetHeight, top));
            fab.style.left = left + 'px';
            fab.style.top = top + 'px';
            fab.style.right = 'auto';
            fab.style.bottom = 'auto';
        }
    });
    
    window.addEventListener('touchmove', (e) => {
        if (isDragging) {
            dragStarted = true;
            const touch = e.touches[0];
            let left = touch.clientX - dragOffsetX;
            let top = touch.clientY - dragOffsetY;
            left = Math.max(0, Math.min(window.innerWidth - fab.offsetWidth, left));
            top = Math.max(0, Math.min(window.innerHeight - fab.offsetHeight, top));
            fab.style.left = left + 'px';
            fab.style.top = top + 'px';
            fab.style.right = 'auto';
            fab.style.bottom = 'auto';
            e.preventDefault();
        }
    });
    
    window.addEventListener('mouseup', () => {
        if (isDragging) {
            isDragging = false;
            fab.style.cursor = 'grab';
            fab.style.transition = '';
            setTimeout(() => {
                if (!dragStarted) {
                    panel.classList.toggle('show');
                }
                dragStarted = false;
            }, 10);
        }
    });
    
    window.addEventListener('touchend', () => {
        if (isDragging) {
            isDragging = false;
            fab.style.cursor = 'grab';
            fab.style.transition = '';
            setTimeout(() => {
                if (!dragStarted) {
                    panel.classList.toggle('show');
                }
                dragStarted = false;
            }, 10);
        }
    });
    
    // ========== KEO THA PANEL ==========
    let panelDragging = false;
    let panelOffsetX, panelOffsetY;
    const panelHeader = document.getElementById('mainMenuHeader');
    
    panelHeader.addEventListener('mousedown', (e) => {
        if (e.target === panelHeader || e.target.classList.contains('main-menu-title')) {
            panelDragging = true;
            panelOffsetX = e.clientX - panel.offsetLeft;
            panelOffsetY = e.clientY - panel.offsetTop;
            panel.style.cursor = 'grabbing';
            e.preventDefault();
        }
    });
    
    panelHeader.addEventListener('touchstart', (e) => {
        const touch = e.touches[0];
        panelDragging = true;
        panelOffsetX = touch.clientX - panel.offsetLeft;
        panelOffsetY = touch.clientY - panel.offsetTop;
        e.preventDefault();
    });
    
    window.addEventListener('mousemove', (e) => {
        if (panelDragging) {
            let left = e.clientX - panelOffsetX;
            let top = e.clientY - panelOffsetY;
            left = Math.min(window.innerWidth - panel.offsetWidth, Math.max(0, left));
            top = Math.min(window.innerHeight - panel.offsetHeight, Math.max(0, top));
            panel.style.left = left + 'px';
            panel.style.top = top + 'px';
            panel.style.right = 'auto';
            panel.style.bottom = 'auto';
        }
    });
    
    window.addEventListener('touchmove', (e) => {
        if (panelDragging) {
            const touch = e.touches[0];
            let left = touch.clientX - panelOffsetX;
            let top = touch.clientY - panelOffsetY;
            left = Math.min(window.innerWidth - panel.offsetWidth, Math.max(0, left));
            top = Math.min(window.innerHeight - panel.offsetHeight, Math.max(0, top));
            panel.style.left = left + 'px';
            panel.style.top = top + 'px';
            panel.style.right = 'auto';
            panel.style.bottom = 'auto';
            e.preventDefault();
        }
    });
    
    window.addEventListener('mouseup', () => { panelDragging = false; panel.style.cursor = 'default'; });
    window.addEventListener('touchend', () => { panelDragging = false; });
    
    // ========== DONG PANEL ==========
    document.getElementById('closeMenuBtn').addEventListener('click', () => {
        panel.classList.remove('show');
    });
    
    // ========== TOGGLE EVENTS ==========
    document.getElementById('toggleAutoClicker').addEventListener('click', (e) => {
        e.stopPropagation();
        toggleStates.autoClicker = !toggleStates.autoClicker;
        GM_setValue('toggle_autoClicker', toggleStates.autoClicker);
        updateToggleUI();
        handleToggle('autoClicker', toggleStates.autoClicker);
    });
    
    document.getElementById('toggleSpeedhack').addEventListener('click', (e) => {
        e.stopPropagation();
        toggleStates.speedhack = !toggleStates.speedhack;
        GM_setValue('toggle_speedhack', toggleStates.speedhack);
        updateToggleUI();
        handleToggle('speedhack', toggleStates.speedhack);
    });
    
    document.getElementById('toggleComing2').addEventListener('click', (e) => {
        e.stopPropagation();
        toggleStates.coming2 = !toggleStates.coming2;
        GM_setValue('toggle_coming2', toggleStates.coming2);
        updateToggleUI();
        handleToggle('coming2', toggleStates.coming2);
    });
    
    document.getElementById('toggleComing3').addEventListener('click', (e) => {
        e.stopPropagation();
        toggleStates.coming3 = !toggleStates.coming3;
        GM_setValue('toggle_coming3', toggleStates.coming3);
        updateToggleUI();
        handleToggle('coming3', toggleStates.coming3);
    });
    
    // Khoi tao
    updateToggleUI();
    
    // Neu da bat truoc do, tu dong load
    if (toggleStates.autoClicker) {
        setTimeout(() => loadAutoClickerScript(), 1000);
    }
    if (toggleStates.speedhack) {
        setTimeout(() => loadSpeedhackScript(), 1000);
    }
    
    console.log('Main menu da san sang!');
    console.log('Auto Clicker & Speedhack controller ready!');
})();