// ==UserScript==
// @name menu
// @description digdig thing (useless)
// @version 0.0.1
// @author delta-1
// @match *://digdig.io/
// @license MIT
// @grant none
// @namespace https://gf.qytechs.cn/users/843887
// ==/UserScript==
const _instantiateStreaming = WebAssembly.instantiateStreaming;
WebAssembly.instantiateStreaming = function () {
return _instantiateStreaming( new Response() );
}
const _instantiate = WebAssembly.instantiate;
WebAssembly.instantiate = function ( buffer, imports ) {
const array = new Uint8Array( buffer );
find( array, [
OP_SELECT,
OP_F64_PROMOTE_F32,
OP_TEE_LOCAL, - 1,
OP_GET_LOCAL, - 1,
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;
} );
return _instantiate( buffer, imports );
}
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 ] !== - 1 && array[ i + j ] !== search[ j ] ) {
continue main;
}
}
callback( i, i + search.length - 1 );
}
}
function Float32ToArray( x ) {
return new Uint8Array( new Float32Array( [ x ] ).buffer );
}
function Float64ToArray( x ) {
return new Uint8Array( new Float64Array( [ x ] ).buffer );
}
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 );
}
} );
let offsetY = window.innerHeight;
CTX.fill = new Proxy( CTX.fill, {
apply( target, ctx, args ) {
Reflect.apply( ...arguments );
if ( temp ) {
const [ x, y, r ] = temp;
temp = null;
offsetY = Math.min( offsetY, window.innerHeight );
const size = 50;
const pointSize = 2;
ctx.save();
ctx.globalAlpha = 0.8;
ctx.translate( 10 + size, offsetY - 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();
offsetY = window.innerHeight;
}
}
} );
let statsText;
const OffscreenContext = typeof OffscreenCanvasRenderingContext2D !== 'undefined' ?
OffscreenCanvasRenderingContext2D.prototype : Context;
OffscreenContext.fillText = new Proxy( OffscreenContext.fillText, {
apply( target, thisArgs, [ text ] ) {
if ( text === 'Stats' ) {
statsText = thisArgs.canvas;
}
return Reflect.apply( ...arguments );
}
} );
OffscreenContext.drawImage = new Proxy( OffscreenContext.drawImage, {
apply( target, thisArgs, [ image ] ) {
if ( image === statsText ) {
offsetY = thisArgs.getTransform().f;
}
return Reflect.apply( ...arguments );
}
} );
'use strict';
const HTML = `
<table style="width:100%" class="greenthing">
<tr>
<td><b style="text-shadow:1px 1px 0 #444">digdig.io menu thing?</td>
<td>
<a>diep.io hybrid and slave my first image!!!!!</a>
<img src="https://share.sketchpad.app/21/5be-db3a-ac1934.png" alt="diep cool pic". style="width:200px;height:100px;">
</div>
</tr>
</table>
`
const styles = `
.greenthing {border: 1px solid green;
padding-left:10px;
padding-right:10px;
border-collapse: collapse;
overflow-y:auto;
word-wrap:break-all;
}
div#greenthing > table, th, td {
}
div#greenthing > button {
font-family: inherit;
font-size: 1em;
}
}
`
const menuStyles = {
position: "absolute",
top: "25%",
width:"50vw",
height:"60vh",
left: "25%",
display: "none",
"background-color": "rgba(0, 80, 89, 1)",
"font-family":'"Montserrat","Verdana"'
}
// <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat">
const menu = document.createElement("div")
for (var prop in menuStyles) {
menu.style[prop] = menuStyles[prop]
}
menu.innerHTML = HTML
menu.id = "dt-menu"
const styleElement = document.createElement("style")
const font = document.createElement("link")
font.rel = "stylesheet"
font.href = "https://fonts.googleapis.com/css?family=Montserrat"
styleElement.innerHTML = styles
document.head.appendChild(styleElement)
document.head.appendChild(font)
document.body.appendChild(menu)
const myEvent = function(event) {
switch (event.key) {
case "Escape":
if (menu.style.display == "none") {
menu.style.display = "block"
console.log("Menu Enabled!")
}
else {
menu.style.display = "none"
console.log("Menu Disabled!")
}
break
}
}
window.addEventListener("keydown",myEvent)
console.log("digdig menu loaded!")