Map Updator

Update Map

当前为 2017-02-26 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Map Updator
// @namespace    http://api.micetigri.fr/
// @version      0.9
// @description  Update Map
// @author       Billysmille
// @match        http://api.micetigri.fr/maps/
// @grant        none
// ==/UserScript==

function updateAll(list) {
    var lsmap = [];
    var i = 0;
    var pattern = new RegExp('@\\d+', 'g');
    var match;
    while ((match = pattern.exec(list))) {
        lsmap.push(match[0]);
    }
    window.setInterval(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')
                    });
                }
            };
            xmlhttp.open('GET', 'http://api.micetigri.fr/maps/' + lsmap[i], true);
            xmlhttp.send();
            i++;
        }
        else {
            location.reload();
        }
        $('.panel-heading').next('.panel-body').html('Updating ' + i + ' of ' + lsmap.length);
    }, 6000);
}

(function () {
    $('title').html('Map Updator');
    $('.panel-title').html('<strong>Up to date</strong>');
    $('.panel-heading').next('.panel-body').html('-');
    $('#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();
        $(this).button('loading');
        updateAll($('#map-list').val());
    });
})();