Map Updator

Update Map

Stan na 26-02-2017. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Map Updator
// @namespace    http://api.micetigri.fr/
// @version      0.6
// @description  Update Map
// @author       Billysmille
// @match        http://api.micetigri.fr/maps/
// @require      https://xmlhttp.googleapis.com/xmlhttp/libs/jquery/3.1.0/jquery.min.js
// @grant        none
// ==/UserScript==

(function (){
    function updateMap() {
        var array = [];
        var pattern = /@\d+/g;
        var match;
        while ((match = pattern.exec($('#lsmap').val()))) {
            array.push(match[0]);
        }
        if (array.length) {
            var i = 0;
            window.setInterval(function () {
                if (i < array.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');
                            var socket = io.connect('http://node.micetigri.fr:443/');
                            socket.emit('map', {
                                map: xmlDoc.getElementById('mapUpdator').getAttribute('map'),
                                id: xmlDoc.getElementById('mapUpdator').getAttribute('session')
                            });
                        }
                    };
                    xmlhttp.open('GET', 'http://api.micetigri.fr/maps/' + array[i], true);
                    xmlhttp.send();
                }
                else {
                    location.reload();
                }
                i++;
            }, 10000);
            $('#lsmap').val('Updating...');
            $('#lsmap').attr('readonly', true);
        }
        else {
            $('#lsmap').val('');
        }
    }
    $(document).ready(function (){
        $('.panel-body:has(#mapUpdator)').html('<input type="text" class="form-control" id="lsmap" placeholder="Enter code to update">');
        $('#lsmap').change(updateMap);
    });
})();