Virtual Manager Stat-sum

Giver summen af stats'ne for hver spiller.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name           Virtual Manager Stat-sum
// @namespace      http://www.mathemaniac.org
// @description    Giver summen af stats'ne for hver spiller.
// @include        http://www.virtualmanager.com/player/index.php*
// @version 0.0.1.20140827095732
// ==/UserScript==

(function(){
    var totalSum = GM_getValue('totalSum',1);
    GM_registerMenuCommand('Vis sum af alle stats ['+(totalSum > 0 ? 'x' : ' ')+']', function() {
        GM_setValue('totalSum',GM_getValue('totalSum',1) ? 0 : 1);
        window.location.reload();
    });
    var delSum = GM_getValue('delSum',1);
    GM_registerMenuCommand('Vis delsum af hver stat-gruppe ['+(delSum > 0 ? 'x' : ' ')+']', function() {
        GM_setValue('delSum',GM_getValue('delSum',1) ? 0 : 1);
        window.location.reload();
    });

    if (totalSum || delSum) {
        var delSummer = Array(0,0,0);
        var i=0;
        var it = document.evaluate('//div[@class="box" and descendant::h2[text()="Egenskaber"]]//td[contains(@class,"right")]//span/text()', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);
        var stat;
        while (stat = it.iterateNext()) {
            delSummer[i++ % 3]+=parseInt(stat.nodeValue);
        }
        if (delSum) {
            var statTable = document.evaluate('//div[@class="box" and descendant::h2[text()="Egenskaber"]]//table', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;
            var delSumTR = document.createElement('tr');
            for(var j=0; j<3; j++) {
                var delSumTDTitel = document.createElement('td');
                delSumTDTitel.setAttribute('style','font-weight: bold; background-color: #20882D; color: #FFF');
                delSumTDTitel.appendChild(document.createTextNode('Sum'));
                delSumTR.appendChild(delSumTDTitel);
                var delSumTDValue = document.createElement('td');
                delSumTDValue.setAttribute('style','font-weight: bold; background-color: #20882D; color: #FFF;');
                delSumTDValue.className = 'right';
                delSumTDValue.appendChild(document.createTextNode(delSummer[j]));
                delSumTR.appendChild(delSumTDValue);
            }
            statTable.appendChild(delSumTR);
        }
        if (totalSum) {
            var overskrift = document.evaluate('//h2[text()="Egenskaber"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;
            overskrift.appendChild(document.createTextNode(" [Sum: "+(delSummer[0]+delSummer[1]+delSummer[2])+"]"));
        }
    }
})();