DigDig.IO X-Ray

Let's you see more in digdig.io

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

  1. // ==UserScript==
  2. // @name DigDig.IO X-Ray
  3. // @namespace https://tampermonkey.net/
  4. // @version 0.0.2
  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. // Changes the shape of the fog to a square.
  24. // Isn't really needed but kinda cool.
  25.  
  26. /*find( array, [
  27. OP_F64_CONST, ...Float64ToArray( 1.4142135623730951 )
  28. ], function ( start, end ) {
  29.  
  30. array.set( Float64ToArray( 1 ), start + 1 );
  31.  
  32. } );*/
  33.  
  34. const _instantiateStreaming = WebAssembly.instantiateStreaming;
  35.  
  36. WebAssembly.instantiateStreaming = function () {
  37.  
  38. return _instantiateStreaming( new Response() );
  39.  
  40. }
  41.  
  42. const _instantiate = WebAssembly.instantiate;
  43.  
  44. WebAssembly.instantiate = function ( buffer, imports ) {
  45.  
  46. const array = new Uint8Array( buffer );
  47.  
  48. find( array, [
  49. OP_BR_TABLE, 7, 4, 4, 4, 2, 4, 1, 3, 0
  50. ], function ( i, end ) {
  51.  
  52. i += 2;
  53.  
  54. for ( ; i <= end; i ++ ) {
  55.  
  56. array[ i ] = 1;
  57.  
  58. }
  59.  
  60. } );
  61.  
  62. find( array, [
  63. OP_F32_CONST, ...Float32ToArray( 2 ),
  64. OP_SET_LOCAL, 28
  65. ], function ( start, end ) {
  66.  
  67. array.set( Float32ToArray( - 1 ), start + 1 );
  68.  
  69. } );
  70.  
  71. return _instantiate( buffer, imports );
  72.  
  73. }
  74.  
  75. function find( array, search, callback ) {
  76.  
  77. main: for ( let i = 0; i < array.length; i ++ ) {
  78.  
  79. for ( let j = 0; j < search.length; j ++ ) {
  80.  
  81. if ( search[ j ] !== - 1 && array[ i + j ] !== search[ j ] ) {
  82.  
  83. continue main;
  84.  
  85. }
  86.  
  87. }
  88.  
  89. callback( i, i + search.length - 1 );
  90.  
  91. }
  92.  
  93. }
  94.  
  95. function Float32ToArray( x ) {
  96.  
  97. return new Uint8Array( new Float32Array( [ x ] ).buffer );
  98.  
  99. }
  100.  
  101. function Float64ToArray( x ) {
  102.  
  103. return new Uint8Array( new Float64Array( [ x ] ).buffer );
  104.  
  105. }