Map Updator

Update Map

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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());
    });
})();