hwm_gi_battles_loader

Загрузка боёв ГИ

当前为 2021-07-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name hwm_gi_battles_loader
  3. // @author omne
  4. // @namespace omne
  5. // @connect daily.heroeswm.ru
  6. // @description Загрузка боёв ГИ
  7. // @version 0.2
  8. // @encoding utf-8
  9. // @include /^https{0,1}:\/\/((www|qrator|)\.(heroeswm|lordswm)\.(ru|com)|178\.248\.235\.15)\/(pl_warlog|war).php/
  10. // @grant GM_xmlhttpRequest
  11. // ==/UserScript==
  12.  
  13. (function() {
  14.  
  15. if (/pl_warlog/.test(location.href)) {
  16. let pers_id = document.documentElement.innerHTML.match(/pl_hunter_stat\.php\?id=([0-9]+)/)[1];
  17. let data = '';
  18. let ch = 0;
  19. let all_ch = 0;
  20. let elem = document.getElementsByClassName('sh_ResourcesItem_icon')[0];
  21.  
  22. if (elem === undefined) {
  23. elem = document.getElementsByClassName('rs')[0];
  24. }
  25.  
  26. elem.addEventListener("click", get_data, false);
  27.  
  28. function get_data() {
  29. let elem = document.getElementsByClassName('global_container_block_header global_a_hover')[0].nextElementSibling;
  30. elem.insertAdjacentHTML("afterbegin", "<center><span id = 'loader'>Загрузка боёв ГИ:</span></center><BR>");
  31. let last_page = get_last_page();
  32. get_page('/pl_warlog.php?id=' + pers_id + '&page=', 0, last_page);
  33. }
  34.  
  35. function get_last_page() {
  36. let result = get_hwm('/pl_warlog.php?id=' + pers_id + '&page=9999999');
  37. return result.match(/<a class=\"active\".+?([0-9]+)/)[1];
  38. }
  39.  
  40. function get_page(url, page, count) {
  41. GM_xmlhttpRequest({
  42. method: "GET",
  43. url: url + page,
  44. onload: function(response) {
  45. let battles = response.responseText.match(/&nbsp;&nbsp;.+?<!--110--><BR>/g);
  46. if (battles !== null) {
  47. for (let j = 0; j < battles.length; j++) {
  48. data = data + battles[j].match(/warid=([0-9]+)/)[1] + "|" + battles[j].match(/show_for_all=([0-9a-zA-Z]+)/)[1] + ";";
  49. ch++;
  50. all_ch++;
  51. }
  52. }
  53. if (ch > 100) {
  54. get_daily('https://daily.heroeswm.ru/services/help/gi.php?data=' + data);
  55. data = '';
  56. ch = 0;
  57. }
  58.  
  59. page++;
  60. if (page <= count) {
  61. document.getElementById('loader').innerHTML = 'Загрузга боёв ГИ: ' + page + '/' + count + '. Боёв найдено: ' + all_ch;
  62. get_page('/pl_warlog.php?id=' + pers_id + '&page=', page, count);
  63. }
  64.  
  65. else {
  66. get_daily('https://daily.heroeswm.ru/services/help/gi.php?data=' + data);
  67. }
  68.  
  69. }
  70. });
  71. }
  72. }
  73.  
  74. if (/war\.php/.test(location.href)) {
  75. let btype = document.documentElement.innerHTML.match(/btypeo\|([0-9]+)/)[1];
  76. if (btype == 110) {
  77. get_daily('https://daily.heroeswm.ru/services/help/gi.php' + location.search);
  78. console.log('https://daily.heroeswm.ru/services/help/gi.php' + location.search);
  79. }
  80. }
  81. function get_daily(url) {
  82. GM_xmlhttpRequest({
  83. method: "GET",
  84. url: url
  85. });
  86. }
  87.  
  88. function get_hwm(url) {
  89. let xhr = new XMLHttpRequest();
  90. xhr.open('GET', url, false);
  91. xhr.send();
  92. return xhr.responseText;
  93. }
  94. })();
  95.