FISK Employee Stat Totals

Add it up

当前为 2018-06-14 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         FISK Employee Stat Totals
// @namespace    https://www.torn.com/factions.php?step=profile&ID=12058
// @version      1
// @description  Add it up
// @author       Ayelis
// @match        https://www.torn.com/companies.php
// @requires     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);
});