DigDig.IO X-Ray

Let's you see more in digdig.io

当前为 2021-09-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name DigDig.IO X-Ray
  3. // @namespace https://tampermonkey.net/
  4. // @version 0.0.8
  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, 9, 4, 1, 0, 3, 4, 4, 2, 4, 4, 0
  39. ], function ( i, end ) {
  40.  
  41. console.log( 'here!!' )
  42.  
  43. i += 2;
  44.  
  45. for ( ; i <= end; i ++ ) {
  46.  
  47. array[ i ] = 1;
  48.  
  49. }
  50.  
  51. } );
  52.  
  53. find( array, [
  54. OP_F32_CONST, ...Float32ToArray( 2 ),
  55. OP_SET_LOCAL, - 1
  56. ], function ( start, end ) {
  57.  
  58. array.set( Float32ToArray( - 1 ), start + 1 );
  59.  
  60. } );
  61.  
  62. // changes the shape of the fog to a rectangle
  63.  
  64. find( array, [
  65. OP_F64_CONST, ...Float64ToArray( 1.4142135623730951 )
  66. ], function ( start, end ) {
  67.  
  68. array.set( Float64ToArray( 1 ), start + 1 );
  69.  
  70. } );
  71.  
  72. return _instantiate( buffer, imports );
  73.  
  74. }
  75.  
  76. function find( array, search, callback ) {
  77.  
  78. main: for ( let i = 0; i < array.length; i ++ ) {
  79.  
  80. for ( let j = 0; j < search.length; j ++ ) {
  81.  
  82. if ( search[ j ] !== - 1 && array[ i + j ] !== search[ j ] ) {
  83.  
  84. continue main;
  85.  
  86. }
  87.  
  88. }
  89.  
  90. callback( i, i + search.length - 1 );
  91.  
  92. }
  93.  
  94. }
  95.  
  96. function Float32ToArray( x ) {
  97.  
  98. return new Uint8Array( new Float32Array( [ x ] ).buffer );
  99.  
  100. }
  101.  
  102. function Float64ToArray( x ) {
  103.  
  104. return new Uint8Array( new Float64Array( [ x ] ).buffer );
  105.  
  106. }