DigDig.IO X-Ray

Let's you see more in digdig.io

目前為 2021-09-09 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name DigDig.IO X-Ray
  3. // @namespace https://tampermonkey.net/
  4. // @version 0.0.4
  5. // @description Let's you see more in digdig.io
  6. // @author Zertalious (Zert)
  7. // @match *://digdig.io/*
  8. // @icon https://www.google.com/s2/favicons?domain=digdig.io
  9. // @require https://cdn.jsdelivr.net/gh/Qwokka/WAIL@9ed21abc43045e19f9b3756de109a6e361fb9292/wail.js
  10. // ==/UserScript==
  11.  
  12. // Only works when fow is done client side
  13. // Should or shouldn't work depending on the current live build
  14. // Created on build: 41e6c4662ebb8e04b62e5ac95c03eb1d8f5427d1
  15.  
  16. // code block ids:
  17. // 4 = lava, diamond, gold, uranium
  18. // 3 = ?? (not empty, maybe some reversed id)
  19. // 0 = dirt
  20. // 1 = quartz
  21. // 2 = bedrock
  22.  
  23. const _instantiateStreaming = WebAssembly.instantiateStreaming;
  24.  
  25. WebAssembly.instantiateStreaming = function () {
  26.  
  27. return _instantiateStreaming( new Response() );
  28.  
  29. }
  30.  
  31. const _instantiate = WebAssembly.instantiate;
  32.  
  33. WebAssembly.instantiate = function ( buffer, imports ) {
  34.  
  35. const array = new Uint8Array( buffer );
  36.  
  37. find( array, [
  38. OP_BR_TABLE, 7, 4, 4, 4, 2, 4, 1, 3, 0
  39. ], function ( i, end ) {
  40.  
  41. i += 2;
  42.  
  43. for ( ; i <= end; i ++ ) {
  44.  
  45. array[ i ] = 1;
  46.  
  47. }
  48.  
  49. } );
  50.  
  51. find( array, [
  52. OP_F32_CONST, ...Float32ToArray( 2 ),
  53. OP_SET_LOCAL, 28
  54. ], function ( start, end ) {
  55.  
  56. array.set( Float32ToArray( - 1 ), start + 1 );
  57.  
  58. } );
  59.  
  60. // Break noob anti-cheat (git gud m28, took me 10 seconds to find)
  61.  
  62. find( array, [
  63. OP_GET_LOCAL, 3,
  64. OP_GET_LOCAL, 28,
  65. OP_F32_GE,
  66. OP_IF, VALUE_TYPE_BLOCK
  67. ], function ( start, end ) {
  68.  
  69. array[ end + 1 ] = OP_BR;
  70. array[ end + 2 ] = 0;
  71.  
  72. } );
  73.  
  74. // changes the shape of the fog to a rectangle
  75.  
  76. find( array, [
  77. OP_F64_CONST, ...Float64ToArray( 1.4142135623730951 )
  78. ], function ( start, end ) {
  79.  
  80. array.set( Float64ToArray( 1 ), start + 1 );
  81.  
  82. } );
  83.  
  84. return _instantiate( buffer, imports );
  85.  
  86. }
  87.  
  88. function find( array, search, callback ) {
  89.  
  90. main: for ( let i = 0; i < array.length; i ++ ) {
  91.  
  92. for ( let j = 0; j < search.length; j ++ ) {
  93.  
  94. if ( search[ j ] !== - 1 && array[ i + j ] !== search[ j ] ) {
  95.  
  96. continue main;
  97.  
  98. }
  99.  
  100. }
  101.  
  102. callback( i, i + search.length - 1 );
  103.  
  104. }
  105.  
  106. }
  107.  
  108. function Float32ToArray( x ) {
  109.  
  110. return new Uint8Array( new Float32Array( [ x ] ).buffer );
  111.  
  112. }
  113.  
  114. function Float64ToArray( x ) {
  115.  
  116. return new Uint8Array( new Float64Array( [ x ] ).buffer );
  117.  
  118. }