DH3 VarViewer

Easy way to view var_ values in DH3

  1. // ==UserScript==
  2. // @name DH3 VarViewer
  3. // @namespace com.anwinity.dh3
  4. // @version 1.2.2
  5. // @description Easy way to view var_ values in DH3
  6. // @author Anwinity
  7. // @match dh3.diamondhunt.co
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. const VarViewer = {
  15. init: function() {
  16. // overwrite navigate to handle new tab
  17. const oldNavigate = window.navigate;
  18. window.navigate = function(a,b,c,d,e,f,g,h,i,j,k,l,m) {
  19. oldNavigate(a,b,c,d,e,f,g,h,i,j,k,l,m);
  20. if(a=="right-vars") {
  21. VarViewer.refresh();
  22. }
  23. else {
  24. $("#navigation-right-vars").hide();
  25. }
  26. };
  27.  
  28. // add some styling (cause we fancy)
  29. const styles = document.createElement("style");
  30. styles.textContent = `
  31. table#vars-table {
  32. border-collapse: collapse;
  33. }
  34. table#vars-table tr, table#vars-table th, table#vars-table td {
  35. border: 1px solid grey;
  36. }
  37. table#vars-table th, table#vars-table td {
  38. padding: 0.25em;
  39. }
  40. `;
  41. $("head").append(styles);
  42.  
  43. // add the button
  44. $("#navigation-area-buttons").append(`
  45. <div onclick="navigate('right-vars')" id="navigation-right-vars-button" class="navigate-button" style="color: white;">
  46. <img src="images/fireIcon.png" class="img-50" />
  47. <br />
  48. <div style="font-size: 10pt; text-align: center;">Vars</div>
  49. </div>`);
  50.  
  51. // add the content
  52. $("#right-panel").append(`
  53. <div id="navigation-right-vars" style="display: none; padding: 1em;">
  54. <div>
  55. <button id="varviewer-clear" type="button">Clear</button>&nbsp;&nbsp;
  56. <input id="varviewer-filter" type="text">&nbsp;&nbsp;
  57. <button id="varviewer-search" type="button">Search</button><br />
  58. <table id="vars-table" style="margin-top: 0.5em">
  59. <thead>
  60. <tr>
  61. <th style="text-align: left">Var Name</th>
  62. <th style="text-align: left">Var Value</th>
  63. </tr>
  64. </thead>
  65. <tbody></tbody>
  66. </table>
  67. </div>
  68. </div>
  69. `);
  70.  
  71.  
  72. $("#varviewer-filter").keypress(function(e) {
  73. if(e.keyCode == 13) {
  74. $("#varviewer-search").click();
  75. }
  76. });
  77. $("#varviewer-clear").click(function() {
  78. $("#varviewer-filter").val("");
  79. VarViewer.refresh();
  80. });
  81. $("#varviewer-search").click(function() {
  82. VarViewer.refresh($("#varviewer-filter").val());
  83. });
  84. },
  85. refresh: function(filter) {
  86. if(filter) {
  87. filter = filter.toLowerCase();
  88. }
  89. const tbody = $("#navigation-right-vars tbody");
  90. tbody.empty();
  91. tbody.append('<tr><td id="vars-table-one-sec" colspan="2">One Sec...</td></tr>');
  92. setTimeout(() => {
  93. Object.keys(window)
  94. .filter(v=>v.startsWith("var_"))
  95. .filter(v=>!filter || v.toLowerCase().includes(filter) || `${window[v]}`.toLowerCase().includes(filter))
  96. .sort()
  97. .forEach(function(v) {
  98. tbody.append(`
  99. <tr>
  100. <td>${v}</td>
  101. <td>${window[v]}</td>
  102. </tr>
  103. `);
  104. });
  105. $("#vars-table-one-sec").remove();
  106. }, 1);
  107.  
  108. }
  109. };
  110.  
  111. VarViewer.init();
  112. })();

QingJ © 2025

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