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.1
  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. elem.addEventListener("click", get_data, false);
  22.  
  23. function get_data() {
  24. let elem = document.getElementsByClassName('global_container_block_header global_a_hover')[0].nextElementSibling;
  25. elem.insertAdjacentHTML("afterbegin", "<center><span id = 'loader'>Загрузка боёв ГИ:</span></center><BR>");
  26. let last_page = get_last_page();
  27. get_page('/pl_warlog.php?id=' + pers_id + '&page=', 0, last_page);
  28. }
  29.  
  30. function get_last_page() {
  31. let result = get_hwm('/pl_warlog.php?id=' + pers_id + '&page=9999999');
  32. return result.match(/<a class=\"active\".+?([0-9]+)/)[1];
  33. }
  34.  
  35. function get_page(url, page, count) {
  36. GM_xmlhttpRequest({
  37. method: "GET",
  38. url: url + page,
  39. onload: function(response) {
  40. let battles = response.responseText.match(/&nbsp;&nbsp;.+?<!--110--><BR>/g);
  41. if (battles !== null) {
  42. for (let j = 0; j < battles.length; j++) {
  43. data = data + battles[j].match(/warid=([0-9]+)/)[1] + "|" + battles[j].match(/show_for_all=([0-9a-zA-Z]+)/)[1] + ";";
  44. ch++;
  45. all_ch++;
  46. }
  47. }
  48. if (ch > 100) {
  49. get_daily('https://daily.heroeswm.ru/services/help/gi.php?data=' + data);
  50. data = '';
  51. ch = 0;
  52. }
  53.  
  54. page++;
  55. if (page <= count) {
  56. document.getElementById('loader').innerHTML = 'Загрузга боёв ГИ: ' + page + '/' + count + '. Боёв найдено: ' + all_ch;
  57. get_page('/pl_warlog.php?id=' + pers_id + '&page=', page, count);
  58. }
  59.  
  60. else {
  61. get_daily('https://daily.heroeswm.ru/services/help/gi.php?data=' + data);
  62. }
  63.  
  64. }
  65. });
  66. }
  67. }
  68.  
  69. if (/war\.php/.test(location.href)) {
  70. let btype = document.documentElement.innerHTML.match(/btypeo\|([0-9]+)/)[1];
  71. if (btype == 110) {
  72. get_daily('https://daily.heroeswm.ru/services/help/gi.php' + location.search);
  73. console.log('https://daily.heroeswm.ru/services/help/gi.php' + location.search);
  74. }
  75. }
  76. function get_daily(url) {
  77. GM_xmlhttpRequest({
  78. method: "GET",
  79. url: url
  80. });
  81. }
  82.  
  83. function get_hwm(url) {
  84. let xhr = new XMLHttpRequest();
  85. xhr.open('GET', url, false);
  86. xhr.send();
  87. return xhr.responseText;
  88. }
  89. })();
  90.