Update Map
当前为
// ==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());
});
})();