Torn Crime Page Optimizer

Remove elements from Torn crime UI that slow things down

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

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