Torn Crime Page Optimizer

Remove elements from Torn crime UI that slow things down

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         Torn Crime Page Optimizer
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  Remove elements from Torn crime UI that slow things down
// @author       Omanpx [1906686] + Gemini
// @match        https://www.torn.com/page.php?sid=crimes*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Remove the animated banners
    function setAriaExpanded() {
        const button = document.querySelector('.toggleStatsPanelButton___ZXzDJ');
        if (button) {
            // Check if it's not already expanded
            if (button.getAttribute('aria-expanded') !== 'true') {
                // Click the button to trigger the expand
                button.click();
                console.log('Clicked toggleStatsPanelButton to expand');
            }
        }

        // Also remove the banner wrapper
        const banner = document.querySelector('.bannerWrapper___uaNe0');
        if (banner) {
            banner.remove();
            console.log('Removed bannerWrapper element');
            return true;
        }

        return false;
    }

    // Run immediately
    setAriaExpanded();

    // Watch for dynamic content changes - observe the entire document
    const observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.addedNodes.length > 0) {
                setAriaExpanded();
            }
        });
    });

    // Start observing the document body for changes
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    // Also try repeatedly for the first few seconds
    let attempts = 0;
    const interval = setInterval(() => {
        if (setAriaExpanded() || attempts > 20) {
            clearInterval(interval);
        }
        attempts++;
    }, 200);

    // Scamming: hide tooltips and animations
        const css = `
        /* Hide tooltips that may cause layout thrashing or lag */
        [class*="tooltip___L0gNl"] {
            display: none !important;
            opacity: 0 !important;
            visibility: hidden !important;
            pointer-events: none !important;
        }

        /* Disable and hide the heavy background line/link animations */
        [class*="linesAnimation___uUpyS"] {
            display: none !important;
            animation: none !important;
            transition: none !important;
        }

        /* Target the specific forward line variations to completely kill their rendering */
        [class*="forStrongForward___Zlath"],
        [class*="forSoftForward___CasAg"] {
            display: none !important;
            animation: none !important;
            transition: none !important;
        }
    `;

    // Inject styles efficiently before the DOM fully renders to prevent visual flashing
    if (typeof GM_addStyle !== 'undefined') {
        GM_addStyle(css);
    } else {
        const style = document.createElement('style');
        style.type = 'text/css';
        style.appendChild(document.createTextNode(css));
        (document.head || document.documentElement).appendChild(style);
    }
})();