UDInventory

(Urban Dead) Groups items together in your inventory and squashes mall search

  1. // ==UserScript==
  2. // @author haliphax
  3. // @include http://*urbandead.com/map.cgi*
  4. // @exclude http://*urbandead.com/map.cgi?log*
  5. // @name UDInventory
  6. // @namespace https://roadha.us
  7. // @description (Urban Dead) Groups items together in your inventory and squashes mall search
  8. // @version 1.1
  9. // ==/UserScript==
  10.  
  11. (function(){
  12. var a = 0;
  13. var matches = 0;
  14. var newform = 0;
  15.  
  16. // pistols
  17. matches = document.body.innerHTML.match(/"pistol" class="m".*?>\([0-9]+\)/g);
  18. if(matches !== null && matches.length > 1)
  19. {
  20. newform = '<form class="a" action="map.cgi?use-b" method="post">';
  21. newform += '<input type="submit" value="';
  22. newform += (matches.length > 1 ? matches.length + ' ' : '') + 'pistol';
  23. newform += (matches.length > 1 ? 's' : '') + '" class="m">&nbsp;<b>';
  24. for(a = 0; a < matches.length; a++) {
  25. newform += matches[a].match(/\([0-9]+\)/);
  26. }
  27. newform += '</b></form>';
  28. document.body.innerHTML = document.body.innerHTML.replace(
  29. /<form action="map\.cgi\?use-b".*?<\/form>/, newform).replace(
  30. /<form action="map\.cgi\?use-b".*?<\/form>/g, '');
  31. }
  32.  
  33. // shotguns
  34. matches = document.body.innerHTML.match(/"shotgun" class="m".*?>\([0-9]+\)/g);
  35. if(matches !== null && matches.length > 1)
  36. {
  37. newform = '<form class="a" action="map.cgi?use-s" method="post">';
  38. newform += '<input type="submit" value="';
  39. newform += (matches.length > 1 ? matches.length + ' ' : '') + 'shotgun';
  40. newform += (matches.length > 1 ? 's' : '') + '" class="m">&nbsp;<b>';
  41. for(a = 0; a < matches.length; a++) {
  42. newform += matches[a].match(/\([0-9]+\)/);
  43. }
  44. newform += '</b></form>';
  45. document.body.innerHTML = document.body.innerHTML.replace(
  46. /<form action="map\.cgi\?use-s".*?<\/form>/, newform).replace(
  47. /<form action="map\.cgi\?use-s".*?<\/form>/g, '');
  48. }
  49.  
  50. // first-aid kits
  51. matches = document.body.innerHTML.match(/"first-aid kit" class="m".*?>/g);
  52. if(matches !== null && matches.length > 1)
  53. {
  54. newform = '<form class="a" action="map.cgi?use-h" method="post">';
  55. newform += '<input type="submit" value="first-aid kit" class="m">&nbsp;<b>(';
  56. newform += matches.length + ')</b>&nbsp;on&nbsp;';
  57. var fakHtml = document.body.innerHTML.match(
  58. /<select name="target"><option value="">self.*?<\/form>/);
  59. if(fakHtml == null) fakHtml = 'self</form>';
  60. newform += fakHtml;
  61. document.body.innerHTML = document.body.innerHTML.replace(
  62. /<form action="map\.cgi\?use-h" method="post" class="a">.*?<\/form>/,
  63. newform).replace(
  64. /<form action="map\.cgi\?use-h" method="post" class="a">.*?<\/form>/g,
  65. '');
  66. }
  67.  
  68. // revivification syringes
  69. matches = document.body.innerHTML.match(/"revivification syringe" class="m".*?>/g);
  70. if(matches !== null && matches.length > 1)
  71. {
  72. newform = '<form class="a" action="map.cgi?use-z" method="post">';
  73. newform += '<input type="submit" value="revivification syringe" class="m">&nbsp;';
  74. newform += '<b>(' + matches.length + ')</b>';
  75. newform += document.body.innerHTML.match(
  76. /"revivification syringe" class="m".*?>(.*?)&nbsp;\(10AP\)<\/form>/)[1];
  77.  
  78. if(document.body.innerHTML.match(/<span class="apw">/) !== null) {
  79. newform += '&nbsp;<span style="color:DarkRed;font-weight:bold;">(10AP)</span>';
  80. } else {
  81. newform += '&nbsp;(10AP)';
  82. }
  83.  
  84. newform += '</form>';
  85. document.body.innerHTML = document.body.innerHTML.replace(
  86. /<form action="map\.cgi\?use-z" method="post" class="a">.*?<\/form>/,
  87. newform).replace(
  88. /<form action="map\.cgi\?use-z" method="post" class="a">.*?<\/form>/g,
  89. '');
  90. }
  91.  
  92. // pistol clips
  93. matches = document.body.innerHTML.match(/"pistol clip" class="m".*?>/g);
  94. if(matches !== null && matches.length > 1)
  95. {
  96. newform = '<form class="a" action="map.cgi?use-k" method="post">';
  97. newform += '<input type="submit" value="pistol clip" class="m">&nbsp;';
  98. newform += '<b>(' + matches.length + ')</b></form>';
  99. document.body.innerHTML = document.body.innerHTML.replace(
  100. /<form action="map\.cgi\?use-k" method="post" class="a">.*?<\/form>/,
  101. newform).replace(
  102. /<form action="map\.cgi\?use-k" method="post" class="a">.*?<\/form>/g,
  103. '');
  104. }
  105.  
  106. // shotgun shells
  107. matches = document.body.innerHTML.match(/"shotgun shell" class="m".*?>/g);
  108. if(matches !== null && matches.length > 1)
  109. {
  110. newform = '<form class="a" action="map.cgi?use-r" method="post">';
  111. newform += '<input type="submit" value="shotgun shell" class="m">&nbsp;';
  112. newform += '<b>(' + matches.length + ')</b></form>';
  113. document.body.innerHTML = document.body.innerHTML.replace(
  114. /<form action="map\.cgi\?use-r" method="post" class="a">.*?<\/form>/,
  115. newform).replace(
  116. /<form action="map\.cgi\?use-r" method="post" class="a">.*?<\/form>/g,
  117. '');
  118. }
  119.  
  120. // spray cans
  121. matches = document.body.innerHTML.match(/"spray can" class="m".*?>/g);
  122. if(matches !== null && matches.length > 1)
  123. {
  124. newform = '<form class="a" action="map.cgi?use-x" method="post">';
  125. newform += '<input type="submit" value="spray can" class="m">&nbsp;';
  126. newform += '<b>(' + matches.length + ')</b></form>';
  127. document.body.innerHTML = document.body.innerHTML.replace(
  128. /<form action="map\.cgi\?use-x" method="post" class="a">.*?<\/form>/,
  129. newform).replace(
  130. /<form action="map\.cgi\?use-x" method="post" class="a">.*?<\/form>/g,
  131. '');
  132. }
  133.  
  134. // fuel cans
  135. matches = document.body.innerHTML.match(/"fuel can" class="m".*?>/g);
  136. if(matches !== null && matches.length > 1)
  137. {
  138. newform = '<form class="a" action="map.cgi?use-i" method="post">';
  139. newform += '<input type="submit" value="fuel can" class="m">&nbsp;';
  140. newform += '<b>(' + matches.length + ')</b></form>';
  141. document.body.innerHTML = document.body.innerHTML.replace(
  142. /<form action="map\.cgi\?use-i" method="post" class="a">.*?<\/form>/,
  143. newform).replace(
  144. /<form action="map\.cgi\?use-i" method="post" class="a">.*?<\/form>/g,
  145. '');
  146. }
  147.  
  148. // mall search compactor
  149. newform = '<form name="srch" id="srch" class="a" action="map.cgi?search'
  150. + (/search.$/.exec(window.location.href)
  151. ? window.location.href[window.location.href.length - 1]
  152. : 'a')
  153. + '" method="post">';
  154. newform += '<input type="submit" value="Search" class="m"><select id="storelist"> ';
  155. newform += '<option value="a" onclick="document.srch.action=\'map.cgi?searcha\'"'
  156. + (/searcha$/.exec(window.location.href) ? ' selected="selected"' : '')
  157. + '>the Gun store</option>';
  158. newform += '<option value="b" onclick="document.srch.action=\'map.cgi?searchb\'"'
  159. + (/searchb$/.exec(window.location.href) ? ' selected="selected"' : '')
  160. + '>the Tech store</option>';
  161. newform += '<option value="c" onclick="document.srch.action=\'map.cgi?searchc\'"'
  162. + (/searchc$/.exec(window.location.href) ? ' selected="selected"' : '')
  163. + '>the Hardware store</option>';
  164. newform += '<option value="d" onclick="document.srch.action=\'map.cgi?searchd\'"'
  165. + (/searchd$/.exec(window.location.href) ? ' selected="selected"' : '')
  166. + '>the Sports store</option>';
  167. newform += '<option value="e" onclick="document.srch.action=\'map.cgi?searche\'"'
  168. + (/searche$/.exec(window.location.href) ? ' selected="selected"' : '')
  169. + '>the Liquor store</option>';
  170. newform += '<option value="f" onclick="document.srch.action=\'map.cgi?searchf\'"'
  171. + (/searchf$/.exec(window.location.href) ? ' selected="selected"' : '')
  172. + '>the Bookstore</option>';
  173. newform += '<option value="g" onclick="document.srch.action=\'map.cgi?searchg\'"'
  174. + (/searchg$/.exec(window.location.href) ? ' selected="selected"' : '')
  175. + '>the Drugstore</option>';
  176. newform += '</select></form>';
  177. document.body.innerHTML = document.body.innerHTML.replace(
  178. /<form action="map\.cgi\?searcha".*?<\/form>/i, newform);
  179. document.body.innerHTML = document.body.innerHTML.replace(
  180. /<form action="map\.cgi\?search[b-g]".*?<\/form>/ig, '');
  181. })();