hwm_battle_add_omne

Отправка ссылок на ивентовые бои к omne

当前为 2020-06-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name hwm_battle_add_omne
  3. // @author Kleshnerukij
  4. // @description Отправка ссылок на ивентовые бои к omne
  5. // @version 1.0
  6. // @include https://www.heroeswm.ru/pl_warlog.php*
  7. // @include https://qrator.heroeswm.ru/pl_warlog.php*
  8. // @include http://178.248.235.15/pl_warlog.php*
  9. // @include https://www.lordswm.com/pl_warlog.php*
  10. // @namespace https://greasyfork.org/ru/scripts/405015-hwm-battle-add-omne
  11. // @encoding utf-8
  12.  
  13. // ==/UserScript==
  14.  
  15. // (c) Клещнерукий - http://www.heroeswm.ru/pl_info.php?id=7076906
  16.  
  17. (function () {
  18. alert(location.href);
  19. var page_content = document.getElementsByTagName('body')[0].innerHTML;
  20. var search_string = /<a href="warlog\.php\?warid=\d+.*?">\d+-\d+-\d+ \d+:\d+<\/a>/igm;
  21. var search_data = /href=\"warlog\.php\?warid=(\d+)\&amp;show_for_all=([a-zA-Z0-9]+)\"/i;
  22. var check_correct = /^\d+-\d+-\d+ \d+:\d+$/i;
  23.  
  24. var res = page_content.match(search_string);
  25. var arr_corr = [];
  26. var step = 0;
  27.  
  28. // Собираем номера строк в которых есть бои с секретной ссылкой
  29. res.forEach(myFunction);
  30. function myFunction(item, index) {
  31. if (item.match(search_data) != null) {
  32. let temp_arr = item.match(search_data);
  33. arr_corr[step] = [temp_arr[1], temp_arr[2]];
  34. }
  35. step++;
  36. }
  37.  
  38. // Добавляем ссылки для пересылки в сервис omne
  39. let elements = document.querySelectorAll('center>table>tbody>tr>td>a');
  40. step = 0;
  41. for (let elem of elements) {
  42. let el = elem.innerHTML;
  43. if (el.search(check_correct) != -1) {
  44. console.log(step);
  45. if (typeof(arr_corr[step]) != "undefined" && arr_corr[step] !== null) {
  46. elem.innerHTML = el+' <a style="color: #000000" href="http://daily.heroeswm.ru/leader_rogues.php?url=warid='+arr_corr[step][0]+'+show_for_all='+arr_corr[step][1]+'"> >> </a>';
  47. } else {
  48. elem.innerHTML = el+' <span style="color: #aaaaaa"> >> </span>';
  49. }
  50. step++;
  51. }
  52. }
  53.  
  54.  
  55. function insertAfter(parent, node, referenceNode) {
  56. parent.insertBefore(node, referenceNode.nextSibling);
  57. }
  58. })();