Attack Percentage Notifier - modded for easier configuration

Highlights weapon slot when enemy HP is below % threshold - configurable

Від 13.09.2025. Дивіться остання версія.

// ==UserScript==
// @name         Attack Percentage Notifier - modded for easier configuration
// @namespace    https://torn.com/
// @version      0.2
// @description  Highlights weapon slot when enemy HP is below % threshold - configurable
// @author       Null[2042113] - mod by GFOUR
// @match        https://www.torn.com/loader.php*
// @run-at       document-idle
// @grant        GM_getValue
// @grant        GM_setValue
// ==/UserScript==

(function() {
    'use strict';

    // Default: 60% if not set before
    let target_health_percent = GM_getValue("target_health_percent", 0.6);

    console.log("[Attack % Notifier] Current threshold: " + (target_health_percent * 100) + "%");

    function doShit() {
        let health_arr = document.querySelectorAll('[id^=player-health-value]');
        if (!health_arr || health_arr.length < 2) return;

        let current = health_arr[1].innerText.split("/")[0].replace(/,/g,'');
        let max = health_arr[1].innerText.split("/")[1].replace(/,/g,'');

        if (parseInt(current) / parseInt(max) <= target_health_percent) {
            let weapon = document.getElementById('weapon_second');
            if (weapon) weapon.style.background = 'red';
        }
    }

    setInterval(doShit, 500);

    // Optional: Allow changing value via console without editing script
    window.setAttackThreshold = function(percent) {
        GM_setValue("target_health_percent", percent);
        console.log("[Attack % Notifier] Threshold updated to " + (percent * 100) + "%");
    };

})();