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.3
// @description  Update Map
// @author       Billysmille
// @match        http://api.micetigri.fr/maps/
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
// @grant        none
// ==/UserScript==

(function (){
    var session;
    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;
            var wait = window.setInterval(function () {
                if (i < array.length) {
                    var socket = io.connect('http://node.micetigri.fr:443/');
                    socket.emit('map', {
                        map: array[i],
                        id: session
                    });
                    i++;
                }
                else {
                    $('#lsmap').val('');
                    $('#lsmap').attr('readonly', false);
                    $('.change-log').append('<p>Finished</p>');
                    window.clearInterval(wait);
                }
            }, 10000);
            $('#lsmap').val('Updating...');
            $('#lsmap').attr('readonly', true);
            $('.change-log').append('<p>' + array.length + ' maps will be updated. Time left: ' + Math.ceil(array.length / 6) + ' minute(s)</p>');
        }
        else {
            $('#lsmap').val('');
            $('.change-log').append('<p>Error</p>');
        }
    }
    $(document).ready(function (){
        session = $('#mapUpdator').attr("session");
        $('.row:has(#MapViewer)').remove();
        $('.panel-body:has(#mapUpdator)').html('<input type="text" class="form-control" id="lsmap" placeholder="Enter code to update">');
        $('.panel-body:has(#copy_this_text)').html('<article class="change-log"></article>');
        $('.change-log').css({
            'height': '190px',
            'overflow': 'auto'
        });
        $('#lsmap').change(updateMap);
    });
})();