battleHelper

Помощь

  1. // ==UserScript==
  2. // @name battleHelper
  3. // @author omne
  4. // @namespace omne
  5. // @description Помощь
  6. // @version 0.38
  7. // @include /^https{0,1}:\/\/((www|qrator|my|h-tst2020)\.(heroeswm|lordswm)\.(ru|com)|178\.248\.235\.15)\/(war|warlog|leader_guild|leader_army|inventory).php(?!.?setkamarmy)/
  8. // @grant GM_xmlhttpRequest
  9. // @license GNU GPLv3
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. var dailyURL = "https://daily.heroeswm.ru/";
  14. let e = document.createElement('script');
  15. e.src = dailyURL + "i/js/dailyJS.js?v=" + Date.now();
  16. document.head.appendChild(e);
  17. if (location.pathname.indexOf("inventory.php") >= 0) {
  18. var inp = "";
  19. var bt = "";
  20. function inv_art_search_show() {
  21. let info = document.getElementById('inv_art_amount');
  22. for (let i = 0; i < info.children.length; i++) {
  23. info.children[i].style.display = "none";
  24. }
  25. if (inp == "") {
  26. inp = document.createElement("input");
  27. inp.setAttribute("placeholder", "Поиск по названию");
  28. inp.setAttribute("type", "text");
  29. inp.setAttribute("id", "inp_search");
  30. info.append(inp);
  31. inp.addEventListener('input', search);
  32. inp.style.display = "inline-block";
  33. bt = document.createElement("button")
  34. bt.innerHTML = "Скрыть поиск";
  35. bt.setAttribute("id", "bt_search");
  36. info.append(bt);
  37. bt.addEventListener('click', hide_search);
  38. bt.style.display = "inline-block";
  39. } else {
  40. bt.style.display = "inline-block";
  41. inp.style.display = "inline-block";
  42. }
  43. start_hide_hwm_hint();
  44. }
  45. function hide_search() {
  46. let info = document.getElementById('inv_art_amount');
  47. for (let i = 0; i < info.children.length; i++) {
  48. info.children[i].style.display = (info.children[i].tagName == "DIV") ? "inline-block" : "none";
  49. }
  50. }
  51. function search() {
  52. let s = document.getElementById("inp_search").value;
  53. let el = document.getElementById("inventory_block");
  54. for (let i = 0; i < el.children.length; i++) {
  55. let id = el.children[i].getAttribute("art_idx");
  56. if (id == null) {
  57. continue;
  58. }
  59. el.children[i].style.display = (arts[id].name.toLowerCase().includes(s.toLowerCase())) ? "block" : "none";
  60. }
  61. }
  62. let sDiv = document.createElement("div");
  63. let sImg = document.createElement("img");
  64. sImg.setAttribute("src", dailyURL + "i/search_logo.png");
  65. sImg.setAttribute("class", "inv_100mwmh");
  66. sDiv.append(sImg);
  67. sDiv.classList.add("divs_inline_right_24");
  68. sDiv.classList.add("btn_hover");
  69. sDiv.classList.add("show_hint");
  70. sDiv.style.right = "28px";
  71. document.getElementById("inv_art_amount").append(sDiv);
  72. sDiv.setAttribute("hint", "Поиск по названию");
  73. sDiv.setAttribute("hwm_hint_added", 1);
  74. sDiv.addEventListener('mousemove', show_hwm_hint);
  75. sDiv.addEventListener('touchstart', show_hwm_hint);
  76. sDiv.addEventListener('mouseout', hide_hwm_hint);
  77. sDiv.addEventListener('touchend', hide_hwm_hint);
  78. sDiv.addEventListener('click', inv_art_search_show);
  79. }
  80. if ((location.pathname.indexOf("war.php") >= 0)||(location.pathname.indexOf("warlog.php") >= 0)) {
  81. let info = "<b>battlehelper отключён</b>";
  82. let elem = [];
  83. elem[0] = document.querySelector("#chat_format");
  84. elem[1] = document.querySelector("#chat_format_classic");
  85. elem[0].innerHTML = info + elem[0].innerHTML;
  86. elem[1].innerHTML = info + elem[1].innerHTML;
  87. }
  88. })();