The West - Mobile Controls

Kontrola gestów mobilnych w The West

目前為 2025-03-29 提交的版本,檢視 最新版本

// ==UserScript==
// @name         The West - Mobile Controls
// @namespace    http://tampermonkey.net/
// @version      3.5
// @description  Kontrola gestów mobilnych w The West
// @author       DK
// @include      https://*.the-west.*/game.php*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Style CSS
    const style = document.createElement('style');
    style.textContent = `
        * {
            touch-action: manipulation;
        }

        body {
            overscroll-behavior-y: none;
            -webkit-user-select: none;
            -webkit-touch-callout: none;
        }
    `;
    document.head.appendChild(style);

    // Kontrola klawiatury i autofocus
    function handleInputs() {
        const inputs = document.querySelectorAll('input, textarea, [contenteditable]');
        inputs.forEach(input => {
            // Początkowa blokada
            if (!input.hasAttribute('data-handled')) {
                input.setAttribute('data-handled', 'true');
                input.setAttribute('readonly', 'readonly');
                input.removeAttribute('autofocus');

                // Odblokuj przy kliknięciu
                input.addEventListener('touchstart', function(e) {
                    this.removeAttribute('readonly');
                    setTimeout(() => this.focus(), 100); // Opóźnione focusowanie
                }, { passive: false });

                // Odblokuj przy kliknięciu myszką (dla testów na PC)
                input.addEventListener('mousedown', function(e) {
                    this.removeAttribute('readonly');
                });
            }
        });
    }

    // Obserwator dla nowych elementów
    const observer = new MutationObserver(() => handleInputs());
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    // Blokada double-tap
    let lastTap = 0;
    document.addEventListener('touchend', function(event) {
        const currentTime = new Date().getTime();
        const tapLength = currentTime - lastTap;
        if (tapLength < 300 && tapLength > 0) {
            event.preventDefault();
        }
        lastTap = currentTime;
    });

    // Blokada podwójnego kliknięcia
    document.addEventListener('dblclick', function(e) {
        e.preventDefault();
    });

    // Blokada pull-to-refresh
    document.addEventListener('touchmove', function(e) {
        if (document.documentElement.scrollTop === 0) {
            e.preventDefault();
        }
    }, { passive: false });

    // Inicjalizacja
    handleInputs();

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址