DH3 SellFix

Allows you to sell items if you are experiencing the bug that doesn't let you.

  1. // ==UserScript==
  2. // @name DH3 SellFix
  3. // @namespace com.anwinity.dh3
  4. // @version 1.0.0
  5. // @description Allows you to sell items if you are experiencing the bug that doesn't let you.
  6. // @author Anwinity
  7. // @match dh3.diamondhunt.co
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. const scope = {
  15. items: null,
  16. defaultKeySort: [
  17. "stone",
  18. "copper",
  19. "iron",
  20. "silver",
  21. "gold",
  22. "promethium",
  23. "titanium",
  24. "ancient",
  25. "moonstone",
  26. "marsRock",
  27. "bronzeBars",
  28. "ironBars",
  29. "silverBars",
  30. "goldBars",
  31. "promethiumBars",
  32. "sapphire",
  33. "emerald",
  34. "ruby",
  35. "diamond",
  36. "bloodDiamond",
  37. "dottedGreenLeaf",
  38. "greenLeaf",
  39. "limeLeaf",
  40. "goldLeaf",
  41. "crystalLeaf",
  42. "stripedGoldLeaf",
  43. "stripedCrystalLeaf",
  44. "logs",
  45. "oakLogs",
  46. "willowLogs",
  47. "mapleLogs",
  48. "bambooLogs",
  49. "lavaLogs",
  50. "pineLogs",
  51. "stardustLogs",
  52. "oyster",
  53. "specialOyster",
  54. "pearl",
  55. "rarePearl",
  56. "limeQuartzMineral",
  57. "jadeMineral",
  58. "amethystMineral",
  59. "blueMarbleMineral",
  60. "limoniteMineral",
  61. "tashmarineMineral",
  62. "denseMarbleMineral",
  63. "fluoriteMineral",
  64. "purpleQuartzMineral",
  65. "crystalPrismeMineral",
  66. "amberMineral",
  67. "tanzaniteMineral",
  68. "royalMineral",
  69. "rainbowCrystalMineral",
  70. "bloodCrystalMineral"
  71. ]
  72. };
  73.  
  74. function initUI() {
  75. const styles = document.createElement("style");
  76. styles.textContent = `
  77. table#sellFixTable {
  78. border-collapse: collapse;
  79. width: 100%;
  80. }
  81. table#sellFixTable tr, table#sellFixTable th, table#sellFixTable td {
  82. border: 1px solid rgb(50, 50, 50);
  83. background-color: rgba(26, 26, 26, 0.4);
  84. text-align: left;
  85. }
  86. table#sellFixTable th, table#sellFixTable td {
  87. padding: 0.25em;
  88. padding-left: 0.5em;
  89. padding-right: 0.5em;
  90. }
  91. `;
  92. $("head").append(styles);
  93.  
  94. $("#navigation-right-shopOptions > center").append(`
  95. <br />
  96. <div onclick="navigate('sellFix')" class="large-shopOptions-buttons">
  97. LET ME SELL THINGS
  98. </div>
  99. `);
  100.  
  101. $("#right-panel").append(`
  102. <div id="navigation-sellFix" style="display: none; padding: 1em;">
  103. <table id="sellFixTable">
  104. <thead>
  105. <tr>
  106. <th>Item</th>
  107. <th>Price Each</th>
  108. <th>You Have</th>
  109. <th>Sell It</th>
  110. </tr>
  111. </thead>
  112. <tbody>
  113.  
  114. </tbody>
  115. </table>
  116. </div>
  117. `);
  118.  
  119. const sellFixTable = $("#sellFixTable");
  120. const itemKeys = Object.keys(scope.items);
  121. itemKeys.sort();
  122. itemKeys.forEach(key => {
  123. if(!scope.defaultKeySort.includes(key)) {
  124. scope.defaultKeySort.push(key);
  125. }
  126. });
  127. scope.defaultKeySort.forEach(name => {
  128. sellFixTable.append(`
  129. <tr id="sellFixRow-${name}">
  130. <td><img src="images/${name}.png" class="img-30" />&nbsp;${name}</td>
  131. <td style="text-align: right">${scope.items[name].toLocaleString()}</td>
  132. <td id="sellFixQuantity-${name}" style="text-align: right"></td>
  133. <td>
  134. <input type="number" min="0" id="sellFixSellAmount-${name}" />
  135. <button type="button" onclick="$('#sellFixSellAmount-${name}').val(parseInt(window.var_${name}||'0'))">Max</button>
  136. <button type="button" onclick="
  137. let amount = parseInt($('#sellFixSellAmount-${name}').val());
  138. if(typeof amount === 'number' && !isNaN(amount)) {
  139. sendBytes('DO_SELL=${name}~'+amount);
  140. }
  141. ">Sell</button>&nbsp;<img src="images/${name}.png" class="img-30" />
  142. </td>
  143. </tr>
  144. `);
  145. });
  146. }
  147.  
  148. function overrideFunctions() {
  149. const originalNavigate = window.navigate;
  150. window.navigate = function(a) {
  151. originalNavigate.apply(this, arguments);
  152. if(a=="sellFix") {
  153. //
  154. }
  155. else {
  156. $("#navigation-sellFix").hide();
  157. }
  158. };
  159.  
  160. const originalSetItems = window.setItems;
  161. window.setItems = function(data) {
  162. originalSetItems.apply(this, arguments);
  163. updateQuantities();
  164. }
  165.  
  166. }
  167.  
  168. function updateQuantities() {
  169. Object.keys(scope.items).forEach(key => {
  170. $(`#sellFixQuantity-${key}`).text(parseInt(window[`var_${key}`]||"0").toLocaleString());
  171. });
  172. }
  173.  
  174. function init() {
  175. if(!window.var_username || !window.global_itemPriceMap || window.global_itemPriceMap.length==0) {
  176. setTimeout(init, 1000);
  177. return;
  178. }
  179.  
  180. scope.items = global_itemPriceMap.reduce((map, item) => {
  181. map[item.name] = parseInt(item.price);
  182. return map;
  183. }, {});
  184. initUI();
  185. overrideFunctions();
  186. updateQuantities();
  187. }
  188.  
  189. $(init);
  190.  
  191. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址