Map Updator

Update Map

目前为 2017-03-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Map Updator
  3. // @namespace api.micetigri.fr
  4. // @version 1.8
  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. i++;
  33. $('.panel-heading').next('.panel-body').html(i + ' of ' + lsmap.length + ' maps');
  34. }
  35. else {
  36. $('.panel-title').html('<strong>Updates</strong>');
  37. $('.panel-heading').next('.panel-body').html(lsmap.length + ' maps updated');
  38. $('#update-button').button('reset');
  39. }
  40. };
  41. $('.panel-title').html('<strong>Updating...</strong>');
  42. $('#update-button').button('loading');
  43. loop();
  44. }
  45. }
  46. $('title').html('Map Updator');
  47. $('.panel-title').html('<strong>Updates</strong>');
  48. $('.panel-heading').next('.panel-body').html('-');
  49. $('#flashMovie').parents('.panel-body').html('<textarea class="form-control" id="map-list" rows="5"></textarea>');
  50. $('#MapViewer').parents('.panel-body').html('<textarea class="form-control" id="map-list" rows="5"></textarea>');
  51. $('#mapUpdator').parents('.panel-body').html('<button type="submit" class="btn btn-default" id="update-button" data-loading-text="Update All...">Update All</button>');
  52. $('#copy_this_text').parents('.row').remove();
  53. $('#update-button').click(function (event) {
  54. event.preventDefault();
  55. updateAll($('#map-list').val());
  56. });
  57. })();