Torn: Unique Stars Highlighter

Highlights the content when a unique star is present in the pickpocketing section.

Από την 10/10/2023. Δείτε την τελευταία έκδοση.

// ==UserScript==
// @name        Torn: Unique Stars Highlighter
// @namespace
// @description Highlights the content when a unique star is present in the pickpocketing section.
// @version     1.0
// @author      Lazerpent
// @match       https://www.torn.com/loader.php?sid=crimes
// @grant       none
// @namespace https://greasyfork.org/users/966900
// ==/UserScript==

(function() {
    'use strict';

    if (window.location.hash !== '#/pickpocketing') {
        return;
    }


    function updateBackgroundColor() {
        const stars = document.querySelectorAll('.uniqueStars___euiiR');
        let hasChildren = false;

        for (const star of stars) {
            if (star.children.length > 0) {
                hasChildren = true;
                break;
            }
        }

        const targetElement = document.querySelector('.content.responsive-sidebar-container.logged-in');
        targetElement.style.backgroundColor = hasChildren ? 'red' : '';
    }

    setInterval(updateBackgroundColor, 500);

})();