Map Updator

Update Map

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         Map Updator
// @namespace    api.micetigri.fr
// @version      1.9
// @description  Update Map
// @author       Billysmille
// @match        http://api.micetigri.fr/maps
// @grant        none
// ==/UserScript==

(function () {
    function updateAll(list) {
        var lsmap = list.match(/@\d+/g);
        if (lsmap) {
            var i = 0;
            var loop = function () {
                if (i < lsmap.length) {
                    var xmlhttp = new XMLHttpRequest();
                    xmlhttp.onreadystatechange = function () {
                        if (this.readyState == 4 && this.status == 200) {
                            var parser = new DOMParser();
                            var xmlDoc = parser.parseFromString(this.responseText, 'text/html');
                            io.connect('http://node.micetigri.fr:443/').emit('map', {
                                map: xmlDoc.getElementById('mapUpdator').getAttribute('map'),
                                id: xmlDoc.getElementById('mapUpdator').getAttribute('session')
                            });
                            window.setTimeout(loop, 10000);
                        }
                    };
                    xmlhttp.open('GET', 'http://api.micetigri.fr/maps/' + lsmap[i], true);
                    xmlhttp.send();
                }
                else {
                    $('.panel-title').html('<strong>Updates</strong>');
                    $('.panel-heading').next('.panel-body').html(lsmap.length + ' maps updated');
                    $('#update-button').button('reset');
                    return;
                }
                i++;
                $('.panel-heading').next('.panel-body').html(i + ' of ' + lsmap.length + ' maps');
            };
            $('.panel-title').html('<strong>Updating...</strong>');
            $('#update-button').button('loading');
            loop();
        }
    }
    $('title').html('Map Updator');
    $('.panel-title').html('<strong>Updates</strong>');
    $('.panel-heading').next('.panel-body').html('-');
    $('#flashMovie').parents('.panel-body').html('<textarea class="form-control" id="map-list" rows="5"></textarea>');
    $('#MapViewer').parents('.panel-body').html('<textarea class="form-control" id="map-list" rows="5"></textarea>');
    $('#mapUpdator').parents('.panel-body').html('<button type="submit" class="btn btn-default" id="update-button" data-loading-text="Update All...">Update All</button>');
    $('#copy_this_text').parents('.row').remove();
    $('#update-button').click(function (event) {
        event.preventDefault();
        updateAll($('#map-list').val());
    });
})();