DigDig.IO Minimap

Fully functional minimap for digdig.io!

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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();

		}

	}
} );