HWM - Resourses as images Style Mod

Заменяет текстовое описание ресурсов на изображения

目前為 2018-11-28 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name HWM - Resourses as images Style Mod
  3. // @namespace Resourses as images
  4. // @author code: Dinozon2, ElMarado; style: sw.East
  5. // @collaborator sw.East
  6. // @version 0.21.2
  7. // @description Заменяет текстовое описание ресурсов на изображения
  8. // @icon http://i.imgur.com/GScgZzY.jpg
  9. // @include https://www.heroeswm.*/pl_info.php*
  10. // @include *//178.248.235.15/pl_info.php*
  11. // @include *//*.lordswm.*/pl_info.php*
  12. // @grant GM_addStyle
  13. // @copyright 2013-2018, sw.East (https://www.heroeswm.ru/pl_info.php?id=3541252)
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. // 0.21.2 - Отображение картинок и ссылок на рынок для частей имперских артов
  18. // 0.21.1 - fix. Отображение картинок для частей имперских артов
  19. /**
  20. * ============= Style =============
  21. */
  22.  
  23. GM_addStyle ( `
  24.  
  25. #box{
  26. width: 93%;
  27. height: 100%;
  28. margin: 0 5px 0 10px;
  29. }
  30. #amount_slot{
  31. overflow: hidden;
  32. float: right;
  33. width: 48px;
  34. height: 48px;
  35. margin: 5px 5px 5px 0;
  36. padding: 0;
  37. border: 3px solid #fff;
  38. box-shadow: 0px 0px 5px #aaa;
  39. z-index: 1;
  40. }
  41. #amount_slot img {
  42. display: block;
  43. width: 42px;
  44. height: 42px;
  45. margin: 3px 0 0 3px;
  46. padding: 0;
  47. }
  48. #amount_slot a img {
  49. -webkit-transition: all 0.2s linear;
  50. -moz-transition: all 0.2s linear;
  51. -ms-transition: all 0.2s linear;
  52. -o-transition: all 0.2s linear;
  53. transition: all 0.2s linear;
  54. }
  55. #amount_slot:hover a img {
  56. -webkit-transform: scale(1.20,1.20);
  57. -moz-transform: scale(1.20,1.20);
  58. -ms-transform: scale(1.20,1.205);
  59. -o-transform: scale(1.20,1.20);
  60. transform: scale(1.20,1.20);
  61. opacity:1;
  62. }
  63. #amount_slot a{
  64. text-decoration: none;
  65. }
  66. .amount_wrap {
  67. position: absolute;
  68. min-width:14px;
  69. height: 13px;
  70. margin: -48px 0 0 -3px;
  71. padding:0 1px 1px;
  72. color:#fff;
  73. border:2px solid #fff;
  74. background:#222;
  75. -webkit-box-shadow: 1px 1px 1px #aaa;
  76. -moz-box-shadow: 1px 1px 1px #aaa;
  77. box-shadow: 1px 1px 1px #aaa;
  78. z-index: 15;
  79. font-size: 10px;
  80. text-align: center;
  81. text-decoration: none !important;
  82. text-shadow: 1px 1px 1px rgba(0,0,0, 0.8);
  83. cursor: pointer;
  84. opacity:.7;
  85. -webkit-transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
  86. -moz-transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
  87. -ms-transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
  88. -o-transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
  89. transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
  90. }
  91.  
  92. ` );
  93. /* Style End */
  94.  
  95.  
  96. var HTMLOut='<div id="box">';
  97.  
  98. var ElementsArray = [];
  99. ElementsArray['Кожа']= 'https://i.imgur.com/Xn82L25.png';
  100. ElementsArray['Сталь']= 'https://i.imgur.com/hwThTJE.png';
  101. ElementsArray['Никель']= 'https://i.imgur.com/6lHniay.png';
  102. ElementsArray['Волшебный порошок']= 'https://i.imgur.com/IuqF7rI.png';
  103. ElementsArray['Мифриловая руда']= 'https://i.imgur.com/dv6rzKn.png';
  104. ElementsArray['Обсидиан']= 'https://i.imgur.com/4yOWbK8.png';
  105. ElementsArray['Мифрил']= 'https://i.imgur.com/1Y1Z7Mq.png';
  106. ElementsArray['Орихалк']= 'https://i.imgur.com/qRGZzCs.png';
  107. ElementsArray['осколок метеорита']= 'meteorit';
  108. ElementsArray['абразив']= 'abrasive';
  109. ElementsArray['змеиный яд']= 'snake_poison';
  110. ElementsArray['клык тигра']= 'tiger_tusk';
  111. ElementsArray['ледяной кристалл']= 'ice_crystal';
  112. ElementsArray['лунный камень']= 'moon_stone';
  113. ElementsArray['огненный кристалл']= 'fire_crystal';
  114. ElementsArray['цветок ведьм']= 'witch_flower';
  115. ElementsArray['цветок ветров']= 'wind_flower';
  116. ElementsArray['цветок папоротника']= 'fern_flower';
  117. ElementsArray['ядовитый гриб']= 'badgrib';
  118. ElementsArray['Имперский арбалет']= 'part_imp_crossbow';
  119. ElementsArray['Имперские сапоги']= 'part_imp_boots';
  120. ElementsArray['Имперский щит']= 'part_imp_shield';
  121. ElementsArray['Имперский шлем']= 'part_imp_helmet';
  122. ElementsArray['Имперский амулет']= 'part_imp_amul';
  123. ElementsArray['Имперский доспех']= 'part_imp_armor';
  124. ElementsArray['Части редкого отряда']= 'https://dcdn.heroeswm.ru/i/army_html/q_sign.png';
  125.  
  126. var a = document.body.getElementsByClassName("wb");
  127.  
  128. for (var i = 0, length = a.length; i < length; i++) {
  129. if (i in a) {
  130. // Находим блок с элементами
  131. if (a[i].innerHTML.indexOf('&nbsp;&nbsp;&nbsp;&nbsp;<b>') + 1){
  132. // создаем массив из строк:
  133. var text=a[i].innerHTML;
  134. console.log(a[i]);
  135. var arr = text.split('<br>');
  136. // очищаем строку от мусора
  137. for (var k=0,len=arr.length;k<len;k++) {
  138. if (k==Math.round((len-1)/2)) {HTMLOut = HTMLOut+'<div id="top">';}
  139. var line=arr[k];
  140.  
  141. line=line.replace('&nbsp;&nbsp;&nbsp;&nbsp;', '');
  142. line=line.replace('<b>', '');
  143. line=line.replace('</b>', '');
  144. var res = line.split(':');
  145.  
  146. // res[0] - название элемента
  147. // res[1] - количество
  148.  
  149. if (res[1]>0) {
  150.  
  151. // фикс ширины
  152. if (res[1]>9999) var w_length = 39;
  153. else if (res[1]>999) var w_length = 31;
  154. else if (res[1]>99) var w_length = 24;
  155. else var w_length = 13;
  156.  
  157. if (res[0].indexOf('\u0418\u043c\u043f\u0435\u0440') !=-1) { //обработка имперских артов }
  158. if(ElementsArray[res[0]].length<24){
  159.  
  160. HTMLOut = HTMLOut + '<div id="amount_slot">'+
  161. '<a href="/auction.php?cat=part&sort=0&art_type='+ElementsArray[res[0]]+'"> '+
  162. '<img src="/i/artifacts/parts/'+ElementsArray[res[0]]+'.png" alt="'+line+'" title="'+line+'">'+
  163. '</a>'+
  164. '<div class="amount_wrap" style="width:'+w_length+'px">'+res[1]+'</div>'+
  165. '</div>';
  166. } else {
  167. HTMLOut = HTMLOut + '<div id="amount_slot">'+
  168. '<a href="#"> '+
  169. '<img src="'+ElementsArray[res[0]]+'" alt="'+line+'" title="'+line+'">'+
  170. '</a>'+
  171. '<div class="amount_wrap" style="width:'+w_length+'px">'+res[1]+'</div>'+
  172. '</div>';
  173. }
  174. } else {
  175. if(ElementsArray[res[0]].length>24){
  176. HTMLOut = HTMLOut + '<div id="amount_slot">'+
  177. '<a href="#"> '+
  178. '<img src="'+ElementsArray[res[0]]+'" alt="'+line+'" title="'+line+'">'+
  179. '</a>'+
  180. '<div class="amount_wrap" style="width:'+w_length+'px">'+res[1]+'</div>'+
  181. '</div>';
  182. } else {
  183. HTMLOut = HTMLOut + '<div id="amount_slot">'+
  184. '<a href="/auction.php?cat=elements&sort=0&art_type='+ElementsArray[res[0]]+'"> '+
  185. '<img src="/i/'+ElementsArray[res[0]]+'.gif" alt="'+line+'" title="'+line+'"> '+
  186. '</a>'+
  187. '<div class="amount_wrap" style="width:'+w_length+'px">'+res[1]+'</div>'+
  188. '</div>';
  189. }
  190. }
  191. }
  192. }
  193.  
  194. HTMLOut = HTMLOut+'</div>';
  195. // Выводим на страницу
  196. a[i].innerHTML = HTMLOut;
  197. }
  198. }
  199. }