Torn Crime Page Optimizer

Remove elements from Torn crime UI that slow things down

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

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