The West - Mobile Controls

Kontrola gestów mobilnych w The West

  1. // ==UserScript==
  2. // @name The West - Mobile Controls
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.5
  5. // @description Kontrola gestów mobilnych w The West
  6. // @author DK
  7. // @include https://*.the-west.*/game.php*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Style CSS
  15. const style = document.createElement('style');
  16. style.textContent = `
  17. * {
  18. touch-action: manipulation;
  19. }
  20.  
  21. body {
  22. overscroll-behavior-y: none;
  23. -webkit-user-select: none;
  24. -webkit-touch-callout: none;
  25. }
  26. `;
  27. document.head.appendChild(style);
  28.  
  29. // Kontrola klawiatury i autofocus
  30. function handleInputs() {
  31. const inputs = document.querySelectorAll('input, textarea, [contenteditable]');
  32. inputs.forEach(input => {
  33. // Początkowa blokada
  34. if (!input.hasAttribute('data-handled')) {
  35. input.setAttribute('data-handled', 'true');
  36. input.setAttribute('readonly', 'readonly');
  37. input.removeAttribute('autofocus');
  38.  
  39. // Odblokuj przy kliknięciu
  40. input.addEventListener('touchstart', function(e) {
  41. this.removeAttribute('readonly');
  42. setTimeout(() => this.focus(), 100); // Opóźnione focusowanie
  43. }, { passive: false });
  44.  
  45. // Odblokuj przy kliknięciu myszką (dla testów na PC)
  46. input.addEventListener('mousedown', function(e) {
  47. this.removeAttribute('readonly');
  48. });
  49. }
  50. });
  51. }
  52.  
  53. // Obserwator dla nowych elementów
  54. const observer = new MutationObserver(() => handleInputs());
  55. observer.observe(document.body, {
  56. childList: true,
  57. subtree: true
  58. });
  59.  
  60. // Blokada double-tap
  61. let lastTap = 0;
  62. document.addEventListener('touchend', function(event) {
  63. const currentTime = new Date().getTime();
  64. const tapLength = currentTime - lastTap;
  65. if (tapLength < 300 && tapLength > 0) {
  66. event.preventDefault();
  67. }
  68. lastTap = currentTime;
  69. });
  70.  
  71. // Blokada podwójnego kliknięcia
  72. document.addEventListener('dblclick', function(e) {
  73. e.preventDefault();
  74. });
  75.  
  76. // Blokada pull-to-refresh
  77. document.addEventListener('touchmove', function(e) {
  78. if (document.documentElement.scrollTop === 0) {
  79. e.preventDefault();
  80. }
  81. }, { passive: false });
  82.  
  83. // Inicjalizacja
  84. handleInputs();
  85.  
  86. })();

QingJ © 2025

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