DigDig.IO Minimap

Fully functional minimap for digdig.io!

Від 02.09.2021. Дивіться остання версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         DigDig.IO Minimap
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  Fully functional minimap for digdig.io!
// @author       Zertalious (Zert)
// @match        *://digdig.io/*
// @icon         https://www.google.com/s2/favicons?domain=digdig.io
// @require      https://cdn.jsdelivr.net/gh/Qwokka/WAIL@9ed21abc43045e19f9b3756de109a6e361fb9292/wail.js
// ==/UserScript==

WebAssembly.instantiateStreaming = async function ( request, imports ) {

	const response = await request;

	const buffer = await response.arrayBuffer();

	return WebAssembly.instantiate( buffer, imports );

}

WebAssembly.instantiate = new Proxy( WebAssembly.instantiate, {
	apply( target, thisArgs, args ) {

		const array = new Uint8Array( args[ 0 ] );

		find( array, [
			OP_SELECT,
			OP_F64_PROMOTE_F32,
			OP_TEE_LOCAL, 'any',
			OP_GET_LOCAL, 'any',
			OP_F64_MUL,
			OP_F64_ADD,
			OP_F64_GE,
			OP_BR_IF, 0
		], function ( start, end ) {

			array[ end - 1 ] = OP_DROP;
			array[ end ] = OP_NOP;

		} );

		args[ 0 ] = array;

		return Reflect.apply( ...arguments );

	}
} );

function find( array, search, callback ) {

	main: for ( let i = 0; i < array.length; i ++ ) {

		for ( let j = 0; j < search.length; j ++ ) {

			if ( search[ j ] === 'any' ? false : array[ i + j ] !== search[ j ] ) {

				continue main;

			}

		}

		callback( i, i + search.length - 1 );

	}

}

const CTX = CanvasRenderingContext2D.prototype;

let temp;

CTX.arc = new Proxy( CTX.arc, {
	apply( target, ctx, args ) {

		if ( [ 25, 28, 3, 50, 9 ].indexOf( args[ 2 ] ) === - 1 && ctx.fillStyle === '#222222' ) {

			temp = args;

		}

		return Reflect.apply( ...arguments );

	}
} );

CTX.fill = new Proxy( CTX.fill, {
	apply( target, ctx, args ) {

		Reflect.apply( ...arguments );

		if ( temp ) {

			const [ x, y, r ] = temp;

			temp = null;

			const size = 50;
			const pointSize = 2;

			ctx.save();

			ctx.globalAlpha = 0.8;

			ctx.translate( 10 + size, ctx.canvas.height - 10 - size );

			ctx.beginPath();

			ctx.arc( 0, 0, size, 0, Math.PI * 2 );

			ctx.fillStyle = '#111';
			ctx.fill();

			ctx.beginPath();

			const a = size - pointSize;

			ctx.arc( ( window.innerWidth / 2 - x ) / r * a, ( window.innerHeight / 2 - y ) / r * a, 2, 0, Math.PI * 2 );

			ctx.fillStyle = '#fff';
			ctx.fill();

			ctx.restore();

			ctx.beginPath();

		}

	}
} );