TORN - Employee Stat Totals

Add it up

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         TORN - Employee Stat Totals
// @namespace    https://www.torn.com/factions.php?step=profile&ID=22887
// @version      1.1
// @description  Add it up
// @author       Ayelis
// @match        https://www.torn.com/companies.php
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js
// ==/UserScript==

function getVal (val) {
    var multiplier = val.substr(-1).toLowerCase();
    if (multiplier == "k"){
        return parseFloat(val) * 1000;
    }else if (multiplier == "m"){
        return parseFloat(val) * 1000000;
    }else if (multiplier == "b"){
        return parseFloat(val) * 1000000000;
    }else{ return val; }
}
function abbrev(num){
    return num > 999999999 ? (num/1000000000).toFixed(1).replace(/\.0$/, '') + 'b' : num > 999999 ? (num/1000000).toFixed(1).replace(/\.0$/, '') + 'm' : num > 999 ? (num/1000).toFixed(1).replace(/\.0$/, '') + 'k' : num
}
$(document).ready(function(){
    window.setInterval(function(){
        var adder=0;
        $('.stats.t-overflow').each(function( index ) {
            $( this ).children('.span-cont').children().remove();
            adder=0;
            $( this ).children('.span-cont').each(function( index ) {
                var num = parseInt(getVal($( this ).text().trim()));
                adder+=num;
            });
            $( this ).attr( "title", abbrev(adder) );
        });
    }, 1000);
});