Speed Hack with Timer (Exclude Multiple Sites)

Speed hack tự động bật, không chạy ở hanaminikata.com và layma.net

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

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

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name         Speed Hack with Timer (Exclude Multiple Sites)
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Speed hack tự động bật, không chạy ở hanaminikata.com và layma.net
// @author       Your Name
// @match        *://*/*
// @exclude      https://hanaminikata.com/*
// @exclude      http://hanaminikata.com/*
// @exclude      https://layma.net/*
// @exclude      http://layma.net/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // Danh sách các web bị chặn
    var blockedSites = [
        'hanaminikata.com',
        'layma.net'
    ];

    // Kiểm tra nếu đang ở web bị chặn thì thoát
    var currentHost = window.location.hostname;
    var isBlocked = blockedSites.some(function(site) {
        return currentHost.includes(site);
    });

    if (isBlocked) {
        console.log("⛔ Speed hack bị vô hiệu hóa trên:", currentHost);
        console.log("📋 Danh sách chặn:", blockedSites.join(', '));
        return;
    }

    console.log("✅ Speed hack được phép trên:", currentHost);

    // Hàm khởi tạo speed hack
    function initSpeedHack() {
        // Kiểm tra nếu đã bật speed hack
        if (window.speedHackEnabled) {
            return;
        }

        console.log("🚀 Đang khởi tạo Speed Hack...");
        console.log("📍 Website hiện tại:", currentHost);

        // Bật speed hack tự động
        window.speedHackEnabled = true;
        var speed = 50; // Tốc độ nhân lên
        
        // Backup các hàm gốc
        window.origRAFBak = window.requestAnimationFrame;
        window.origSTBak = window.setTimeout;
        window.origSIBak = window.setInterval;
        window.origDateBak = Date.now;
        window.origPerfBak = performance.now;
        
        var elapsed = 0;
        var realSeconds = 0;
        
        // Override requestAnimationFrame
        window.requestAnimationFrame = function(cb) {
            return window.origRAFBak(function(t) {
                for (var i = 0; i < speed; i++) {
                    try {
                        cb(t);
                    } catch(e) {
                        // Bỏ qua lỗi
                    }
                }
            });
        };
        
        // Override setTimeout
        window.setTimeout = function(fn, delay) {
            var args = Array.prototype.slice.call(arguments, 2);
            var newDelay = Math.max(1, delay / speed);
            return window.origSTBak.apply(window, [function() {
                try {
                    fn.apply(null, args);
                } catch(e) {
                    // Bỏ qua lỗi
                }
            }, newDelay]);
        };
        
        // Override setInterval
        window.setInterval = function(fn, interval) {
            var args = Array.prototype.slice.call(arguments, 2);
            var newInterval = Math.max(1, interval / speed);
            return window.origSIBak.apply(window, [function() {
                try {
                    fn.apply(null, args);
                } catch(e) {
                    // Bỏ qua lỗi
                }
            }, newInterval]);
        };
        
        // Override Date.now
        Date.now = function() {
            return window.origDateBak() + elapsed;
        };
        
        // Override performance.now
        performance.now = function() {
            return window.origPerfBak() + elapsed;
        };
        
        // Cập nhật thời gian ảo
        window.speedInterval = window.origSIBak(function() {
            elapsed += 16 * (speed - 1);
        }, 16);
        
        // Tạo timer hiển thị
        createTimer();
        
        // Cập nhật timer mỗi giây
        window.timerInterval = window.origSIBak(function() {
            realSeconds++;
            var mins = Math.floor(realSeconds / 60);
            var secs = realSeconds % 60;
            var str = (mins < 10 ? "0" : "") + mins + ":" + (secs < 10 ? "0" : "") + secs;
            if (window.timerDisplay) {
                window.timerDisplay.textContent = "⚡ " + str + " | " + speed + "x";
            }
        }, 1000);
        
        // Thêm shortcut để tắt (Ctrl+Shift+S)
        document.addEventListener('keydown', function(e) {
            if (e.ctrlKey && e.shiftKey && e.key === 'S') {
                e.preventDefault();
                toggleSpeedHack();
            }
        });
        
        console.log("✅ Speed hack " + speed + "x đã được bật!");
        console.log("🕹️ Nhấn Ctrl+Shift+S để tắt/bật");
        
        // Hiển thị thông báo
        showNotification("⚡ Speed " + speed + "x đã bật!");
    }
    
    // Hàm tạo timer
    function createTimer() {
        // Xóa timer cũ nếu có
        if (window.timerDisplay && window.timerDisplay.parentNode) {
            window.timerDisplay.parentNode.removeChild(window.timerDisplay);
        }
        
        window.timerDisplay = document.createElement("div");
        window.timerDisplay.id = "speed-hack-timer";
        window.timerDisplay.style.cssText = `
            position: fixed;
            top: 10px;
            right: 10px;
            background: rgba(0, 0, 0, 0.9);
            color: #00ff00;
            font-family: 'Courier New', monospace;
            font-size: 20px;
            font-weight: bold;
            padding: 10px 18px;
            border-radius: 8px;
            z-index: 999999;
            border: 2px solid #00ff00;
            box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
            text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
            user-select: none;
            pointer-events: none;
            backdrop-filter: blur(5px);
        `;
        window.timerDisplay.textContent = "⚡ 00:00 | 50x";
        
        // Đợi body load
        var checkBody = setInterval(function() {
            if (document.body) {
                clearInterval(checkBody);
                document.body.appendChild(window.timerDisplay);
            }
        }, 100);
    }
    
    // Hàm toggle speed hack
    function toggleSpeedHack() {
        if (window.speedHackEnabled) {
            // Tắt speed hack
            window.speedHackEnabled = false;
            window.requestAnimationFrame = window.origRAFBak;
            window.setTimeout = window.origSTBak;
            window.setInterval = window.origSIBak;
            Date.now = window.origDateBak;
            performance.now = window.origPerfBak;
            
            if (window.speedInterval) {
                clearInterval(window.speedInterval);
            }
            if (window.timerInterval) {
                clearInterval(window.timerInterval);
            }
            if (window.timerDisplay && window.timerDisplay.parentNode) {
                window.timerDisplay.parentNode.removeChild(window.timerDisplay);
            }
            
            console.log("⏹️ Speed hack đã tắt");
            showNotification("⏹️ Speed hack đã tắt!");
        } else {
            // Bật lại speed hack
            initSpeedHack();
        }
    }
    
    // Hàm hiển thị thông báo
    function showNotification(message) {
        var notification = document.createElement("div");
        notification.style.cssText = `
            position: fixed;
            top: 80px;
            right: 20px;
            background: rgba(0, 0, 0, 0.95);
            color: #00ff00;
            font-family: Arial, sans-serif;
            font-size: 16px;
            padding: 15px 25px;
            border-radius: 8px;
            z-index: 999999;
            border-left: 4px solid #00ff00;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
            animation: slideIn 0.5s ease;
            user-select: none;
            pointer-events: none;
            backdrop-filter: blur(5px);
        `;
        notification.textContent = message;
        
        // Thêm animation keyframes
        if (!document.getElementById('speed-hack-styles')) {
            var style = document.createElement('style');
            style.id = 'speed-hack-styles';
            style.textContent = `
                @keyframes slideIn {
                    from {
                        transform: translateX(100px);
                        opacity: 0;
                    }
                    to {
                        transform: translateX(0);
                        opacity: 1;
                    }
                }
            `;
            document.head.appendChild(style);
        }
        
        document.body.appendChild(notification);
        
        // Tự động xóa sau 3 giây
        setTimeout(function() {
            if (notification.parentNode) {
                notification.style.opacity = '0';
                notification.style.transition = 'opacity 0.5s';
                setTimeout(function() {
                    if (notification.parentNode) {
                        notification.parentNode.removeChild(notification);
                    }
                }, 500);
            }
        }, 3000);
    }
    
    // Chạy khi DOM ready
    function startWhenReady() {
        if (document.body) {
            initSpeedHack();
        } else {
            document.addEventListener('DOMContentLoaded', initSpeedHack);
        }
    }
    
    // Thử khởi tạo ngay lập tức
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', startWhenReady);
    } else {
        startWhenReady();
    }
    
    // Thử lại nếu chưa chạy được
    setTimeout(function() {
        if (!window.speedHackEnabled) {
            console.log("🔄 Thử khởi tạo lại speed hack...");
            initSpeedHack();
        }
    }, 2000);
    
})();