TTRS Hack Panel (Clean)

Fixed syntax + working

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         TTRS Hack Panel (Clean)
// @namespace    https://example.com/ttrs-helper
// @version      6.6
// @description  Fixed syntax + working
// @author       You
// @license      MIT
// @match        https://play.ttrockstars.com/*
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  let delayMs = 500;
  let tickHandle = null;
  let autoEnabled = false;
  let hidden = false;

  // ===== GUI =====
  const gui = document.createElement('div');
  gui.style.position = 'fixed';
  gui.style.top = '20px';
  gui.style.right = '20px';
  gui.style.background = '#222';
  gui.style.color = '#fff';
  gui.style.padding = '10px';
  gui.style.zIndex = '99999';

  const status = document.createElement('div');
  status.textContent = 'OFF (M)';
  gui.appendChild(status);

  document.body.appendChild(gui);

  // ===== Overlay =====
  const overlay = document.createElement('div');
  overlay.style.position = 'fixed';
  overlay.style.top = '0';
  overlay.style.left = '0';
  overlay.style.width = '100%';
  overlay.style.height = '100%';
  overlay.style.background = 'rgba(0,0,0,0.8)';
  overlay.style.color = '#0f0';
  overlay.style.display = 'none';
  overlay.style.alignItems = 'center';
  overlay.style.justifyContent = 'center';
  overlay.style.fontSize = '40px';
  overlay.style.zIndex = '100000';
  overlay.textContent = 'RUNNING';
  document.body.appendChild(overlay);

  function tick() {
    const x = window.innerWidth / 2;
    const y = window.innerHeight / 2;
    const el = document.elementFromPoint(x, y);
    if (el) el.click();
  }

  function start() {
    autoEnabled = true;
    status.textContent = 'ON';
    overlay.style.display = 'flex';
    tickHandle = setInterval(tick, delayMs);
  }

  function stop() {
    autoEnabled = false;
    status.textContent = 'OFF';
    overlay.style.display = 'none';
    clearInterval(tickHandle);
  }

  // ===== CONTROLS =====
  document.addEventListener('keydown', (e) => {

    if (e.key.toLowerCase() === 'm') {
      autoEnabled ? stop() : start();
    }

    if (e.key === 'Tab') {
      e.preventDefault();
      hidden = true;
      gui.style.display = 'none';
      overlay.style.display = 'none';
    }

    if (e.key === 'Escape') {
      hidden = false;
      gui.style.display = 'block';
      if (autoEnabled) overlay.style.display = 'flex';
    }

  });

})();