Torn Crime Page Optimizer

Remove elements from Torn crime UI that slow things down

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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);
    }
})();