HWM - Resourses as images Style Mod

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

当前为 2018-11-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name HWM - Resourses as images Style Mod
  3. // @namespace Resourses as images
  4. // @author code: Dinozon2; style: sw.East
  5. // @collaborator sw.East
  6. // @version 0.21.22
  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 -5px;
  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/F1Z7yW3.jpg';
  100. ElementsArray['Сталь']= 'https://i.imgur.com/b3VnoBD.jpg';
  101. ElementsArray['Никель']= 'https://i.imgur.com/1xz12VY.jpg';
  102. ElementsArray['Волшебный порошок']= 'https://i.imgur.com/Z3rdBjl.jpg';
  103. ElementsArray['Мифриловая руда']= 'https://i.imgur.com/BQ0K4gk.jpg';
  104. ElementsArray['Обсидиан']= 'https://i.imgur.com/mij3nGD.jpg';
  105. ElementsArray['Мифрил']= 'https://i.imgur.com/rxvwEiv.jpg';
  106. ElementsArray['Орихалк']= 'https://i.imgur.com/ee1BS1x.jpg';
  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.  
  125. var a = document.body.getElementsByClassName("wb");
  126.  
  127. for (var i = 0, length = a.length; i < length; i++) {
  128. if (i in a) {
  129. // Находим блок с элементами
  130. if (a[i].innerHTML.indexOf('&nbsp;&nbsp;&nbsp;&nbsp;<b>') + 1){
  131. // создаем массив из строк:
  132. var text=a[i].innerHTML;
  133. console.log(a[i]);
  134. var arr = text.split('<br>');
  135. // очищаем строку от мусора
  136. for (var k=0,len=arr.length;k<len;k++) {
  137. if (k==Math.round((len-1)/2)) {HTMLOut = HTMLOut+'<div id="top">';}
  138. var line=arr[k];
  139.  
  140. line=line.replace('&nbsp;&nbsp;&nbsp;&nbsp;', '');
  141. line=line.replace('<b>', '');
  142. line=line.replace('</b>', '');
  143. var res = line.split(':');
  144.  
  145. // res[0] - название элемента
  146. // res[1] - количество
  147.  
  148. if (res[1]>0) {
  149.  
  150. // фикс ширины
  151. if (res[1]>9999) var w_length = 39;
  152. else if (res[1]>999) var w_length = 31;
  153. else if (res[1]>99) var w_length = 24;
  154. else var w_length = 13;
  155.  
  156. if (res[0].indexOf('\u0418\u043c\u043f\u0435\u0440') !=-1) { //обработка имперских артов }
  157. if(ElementsArray[res[0]].length<24){
  158.  
  159. HTMLOut = HTMLOut + '<div id="amount_slot">'+
  160. '<a href="/auction.php?cat=part&sort=0&art_type='+ElementsArray[res[0]]+'"> '+
  161. '<img src="/i/artifacts/parts/'+ElementsArray[res[0]]+'.png" alt="'+line+'" title="'+line+'">'+
  162. '</a>'+
  163. '<div class="amount_wrap" style="width:'+w_length+'px">'+res[1]+'</div>'+
  164. '</div>';
  165. }
  166. } else {
  167. if(ElementsArray[res[0]].length>24){
  168. HTMLOut = HTMLOut + '<div id="amount_slot">'+
  169. '<a href="#"> '+
  170. '<img src="'+ElementsArray[res[0]]+'" alt="'+line+'" title="'+line+'">'+
  171. '</a>'+
  172. '<div class="amount_wrap" style="width:'+w_length+'px">'+res[1]+'</div>'+
  173. '</div>';
  174. } else {
  175. HTMLOut = HTMLOut + '<div id="amount_slot">'+
  176. '<a href="/auction.php?cat=elements&sort=0&art_type='+ElementsArray[res[0]]+'"> '+
  177. '<img src="/i/'+ElementsArray[res[0]]+'.gif" alt="'+line+'" title="'+line+'"> '+
  178. '</a>'+
  179. '<div class="amount_wrap" style="width:'+w_length+'px">'+res[1]+'</div>'+
  180. '</div>';
  181. }
  182. }
  183. }
  184. }
  185.  
  186. HTMLOut = HTMLOut+'</div>';
  187. // Выводим на страницу
  188. a[i].innerHTML = HTMLOut;
  189. }
  190. }
  191. }