Statify Official WoT Forums

Adds WoTLabs stats to the official forums

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

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

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        Statify Official WoT Forums
// @namespace   BocajSretep
// @description Adds WoTLabs stats to the official forums
// @include     http://forum.worldoftanks.com/*
// @version     1.2
// @grant       none
// ==/UserScript==
(function statifyWotForums() {
    var poasts = document.querySelectorAll('.post_block'),
        fragment = document.createDocumentFragment(),
        listItem = document.createElement('li'),
        nmDiv = document.createElement('div'),
        nmLink = document.createElement('a'),
        wlDiv = document.createElement('div'),
        wlLink = document.createElement('a'),
        sigDiv = document.createElement('div'),
        statsSig = document.createElement('img'),
        cssRules = document.createElement('style'),
        playerName;
    
    cssRules.innerHTML = '.wotLabsStats{width: 107px; padding: 2px; margin-top: 5px; background: white; border: 1px solid grey; overflow-x: hidden; transition: width 500ms}.wotLabsStats:hover{width: 472px}.statsLink:before {content: "";display: inline-block;height: 0;width: 0;margin-right: 0.5em;border-left: 4px solid #5A5A5A;border-top: 4px solid transparent;border-bottom: 4px solid transparent;}.statsLink{margin-top: 5px;}';
    document.head.appendChild(cssRules);
    
    
    listItem.classList.add('desc');
    listItem.classList.add('stats');
    
    nmDiv.classList.add('statsLink');
    wlDiv.classList.add('statsLink');
    sigDiv.classList.add('wotLabsStats');
    
    nmLink.innerHTML = 'NoobMeter';
    wlLink.innerHTML = 'WotLabs';
    
    nmDiv.appendChild(nmLink);
    listItem.appendChild(nmDiv);
    wlDiv.appendChild(wlLink);
    listItem.appendChild(wlDiv);
    sigDiv.appendChild(statsSig);
    listItem.appendChild(sigDiv);
    fragment.appendChild(listItem);
    
    for(var i = 0; i < poasts.length; ++i) {
        playerName = poasts[i].querySelector('.name').getAttribute('hovercard-id');
        
        nmLink.href = "http://www.noobmeter.com/player/na/" + playerName;
        wlLink.href = "http://wotlabs.net/na/player/" + playerName;
        statsSig.src = "http://wotlabs.net/sig/na/" + playerName + "/signature.png"
        
        poasts[i].querySelector('.basic_info').appendChild(fragment.cloneNode(true));
        
    }
})();