DigDig.IO Minimap

Fully functional minimap for digdig.io!

2021-09-02 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==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();

		}

	}
} );