Visible Bonus

Shows some info in Attack Logs

当前为 2025-06-26 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Visible Bonus
// @version      1.0
// @description  Shows some info in Attack Logs
// @author       Elvay [3095345]
// @match        https://www.torn.com/loader.php?sid=attackLog&ID=*
// @match        https://www.torn.com/loader.php?sid=attack&user2ID=*
// @namespace https://greasyfork.org/users/1279378
// ==/UserScript==

'use strict';

function colorByType(type){

    switch(type) {
        case "crit":
            return '#FF0000';
            break;
        case "leave":
        case "hospitalize":
        case "mug":
        case "lose":
            return '#000000'
            break;
        case "grenade":
            return '#FFA500';
            break;
        default:
            return '#0000FF'
    }
}

var list = document.querySelector('ul[class^="log-list"]');
if(list==null){
    list= document.querySelector('ul[class^="list"]')
}

const exclusions = ["damage","miss","reloading"]
list.querySelectorAll('li').forEach(e => {
    const span = e.querySelector('span[class^="attacking-events-"]');
    const msg = e.querySelector('span.message');
    if (span && msg) {
        const type = span.className.replace("attacking-events-", "").replace("standart-","").replace("attack-","").replace("critical-hit","crit").replace("-use","");
        const tag = document.createElement('span');
        tag.textContent = `${type}`;
        tag.style.color = '#FFF';
        tag.style.background= colorByType(type);
        tag.style.display = 'inline-block'
        tag.style.width = 'fit-content'
        tag.style.fontSize = '11px';
        tag.style.borderRadius = '5px';
        tag.style.padding = '2px 4px';
        tag.style.fontWeight = 'bold';
        tag.style.margin= '0px 0px 0px 0px';
        tag.style.textTransform = 'uppercase';

        if(!exclusions.includes(type)){
            msg.prepend(tag);
        }
    }
});