NorkoScript

Viva el Lider carajo

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         NorkoScript
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Viva el Lider carajo
// @author       You
// @match        https://www.managerzone.com/*
// @icon         https://i.ibb.co/bzDTnT0/s-nk.gif
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var flag_nk = 'https://i.ibb.co/bzDTnT0/s-nk.gif';
    var flag_ar = 'nocache-758/img/flags/s_ar.gif';
    var flag_ar_2 = 'img/flags/s_ar.gif';
    var round_nk = 'https://i.ibb.co/q0cmsrm/nk-round2.png';
    var round_ar = 'nocache-758/img/flags/15/ar.png';
    var round_ar_2 = 'nocache-758/img/flags/10/ar.png';
    var nk_fed = 'https://www.managerzone.com/?p=federations&fid=1807';

    Run();

    function Run() {
        if(hasRoundFlag()) {
            var checkExist = setInterval(function() {
                if (document.getElementById('thePlayers_0')) {
                    replaceRoundFlags();
                    clearInterval(checkExist);
                }
            }, 1000);
        }
        replaceFlags();
        replaceFlagsForum();
        replaceCountry();
    }

    function hasRoundFlag() {
        if(window.location.href == 'https://www.managerzone.com/?p=transfer' ||
          window.location.href == 'https://www.managerzone.com/?p=worldmap') {
            return true;
        }
        else {
            return false;
        }
    }

    function replaceFlags() {
        let allImgs = document.getElementsByTagName("img");
        for (var i = 0; i < allImgs.length; ++i) {
            if(allImgs[i].attributes.src.value == flag_ar || allImgs[i].attributes.src.value == flag_ar_2) {
                allImgs[i].attributes.src.value = flag_nk;
                if(allImgs[i].attributes.title) {
                    allImgs[i].attributes.title.nodeValue = 'Corea del Norte';
                }
            }
        }
    }

    function replaceFlagsForum() {
        let all = document.getElementsByClassName("topics-col-author");
        for (var i = 0; i < all.length; ++i) {
            if(all[i].children.length > 2) {
                if(all[i].children[2].href == nk_fed) {
                    all[i].children[1].children[0].attributes.src.value = round_nk;
                }
            }
        }
    }

    function replaceRoundFlags() {
        var allImgs = document.getElementsByTagName('img');
        for (var i = 0; i < allImgs.length; ++i) {
            if(allImgs[i].attributes.src.value == round_ar || allImgs[i].attributes.src.value == round_ar_2) {
                allImgs[i].attributes.src.value = round_nk;
                allImgs[i].attributes.title.nodeValue = 'Corea del Norte';
            }
        }
    }

    function replaceCountry() {
        let allTxt = document.getElementsByClassName("nobreak bold");
        for (var i = 0; i < allTxt.length; ++i) {
            if(allTxt[i].textContent == 'Argentina') {
                allTxt[i].textContent = 'Corea del Norte';
            }
        }
    }
})();