Map Updator

Update Map

  1. // ==UserScript==
  2. // @name Map Updator
  3. // @namespace api.micetigri.fr
  4. // @version 1.9
  5. // @description Update Map
  6. // @author Billysmille
  7. // @match http://api.micetigri.fr/maps
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. function updateAll(list) {
  13. var lsmap = list.match(/@\d+/g);
  14. if (lsmap) {
  15. var i = 0;
  16. var loop = function () {
  17. if (i < lsmap.length) {
  18. var xmlhttp = new XMLHttpRequest();
  19. xmlhttp.onreadystatechange = function () {
  20. if (this.readyState == 4 && this.status == 200) {
  21. var parser = new DOMParser();
  22. var xmlDoc = parser.parseFromString(this.responseText, 'text/html');
  23. io.connect('http://node.micetigri.fr:443/').emit('map', {
  24. map: xmlDoc.getElementById('mapUpdator').getAttribute('map'),
  25. id: xmlDoc.getElementById('mapUpdator').getAttribute('session')
  26. });
  27. window.setTimeout(loop, 10000);
  28. }
  29. };
  30. xmlhttp.open('GET', 'http://api.micetigri.fr/maps/' + lsmap[i], true);
  31. xmlhttp.send();
  32. }
  33. else {
  34. $('.panel-title').html('<strong>Updates</strong>');
  35. $('.panel-heading').next('.panel-body').html(lsmap.length + ' maps updated');
  36. $('#update-button').button('reset');
  37. return;
  38. }
  39. i++;
  40. $('.panel-heading').next('.panel-body').html(i + ' of ' + lsmap.length + ' maps');
  41. };
  42. $('.panel-title').html('<strong>Updating...</strong>');
  43. $('#update-button').button('loading');
  44. loop();
  45. }
  46. }
  47. $('title').html('Map Updator');
  48. $('.panel-title').html('<strong>Updates</strong>');
  49. $('.panel-heading').next('.panel-body').html('-');
  50. $('#flashMovie').parents('.panel-body').html('<textarea class="form-control" id="map-list" rows="5"></textarea>');
  51. $('#MapViewer').parents('.panel-body').html('<textarea class="form-control" id="map-list" rows="5"></textarea>');
  52. $('#mapUpdator').parents('.panel-body').html('<button type="submit" class="btn btn-default" id="update-button" data-loading-text="Update All...">Update All</button>');
  53. $('#copy_this_text').parents('.row').remove();
  54. $('#update-button').click(function (event) {
  55. event.preventDefault();
  56. updateAll($('#map-list').val());
  57. });
  58. })();