Greasy Fork is available in English.

Zoom Hack concept (patched)

Zoom functionality with canvas size adjustments

// ==UserScript==
// @name         Zoom Hack concept (patched)
// @namespace    http://tampermonkey.net/
// @version      0.0.4
// @description  Zoom functionality with canvas size adjustments
// @author       r!PsAw
// @match        https://diep.io/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=diep.io
// @grant        none
// @license     MIT
// ==/UserScript==

/*
Zoom in = T
Zoom out = G
Turn on Canvas Mouse = V
*/


// Initial zoom level
let zoomLevel = 1;

// Resize and center the canvas
function resizeAndCenterCanvas() {
    const canvas = document.querySelector('canvas');

    if (canvas) {
        const viewportWidth = window.innerWidth;
        const viewportHeight = window.innerHeight;

        const newWidth = viewportWidth * zoomLevel;
        const newHeight = viewportHeight * zoomLevel;

        canvas.style.position = 'fixed';
        canvas.style.zIndex = '1';
        canvas.style.left = '50%';
        canvas.style.top = '50%';
        canvas.style.width = `${newWidth}px`;
        canvas.style.height = `${newHeight}px`;
        canvas.style.transform = 'translate(-50%, -50%)';
        canvas.style.cursor = 'none';
    }
}

// Adjust mouse coordinates based on zoom level
function adjustMouseCoordinates(x, y) {
    return {
        x: x / zoomLevel,
        y: y / zoomLevel
    };
}

// Handle mouse movement and adjust coordinates
let x; let y;
document.onmousemove = function(e) {
    x = e.clientX;
    y = e.clientY;
}

let mouse_visible = true;
// Handle key presses for zooming
document.onkeydown = function(e) {
    switch (e.keyCode) {
        case 84: // 'T' key
            zoomLevel += 0.1;
            resizeAndCenterCanvas();
            break;
        case 71: // 'G' key
            zoomLevel = Math.max(0.1, zoomLevel - 0.1); // Prevent zoomLevel from becoming negative or zero
            resizeAndCenterCanvas();
            break;
        case 86: // 'V' key
            mouse_visible = !mouse_visible;
            if(mouse_visible){
                document.body.style.cursor = "default";
            }else{
                document.body.style.cursor = "none";
            }
            break
    }
}

//gui
const ctx = canvas.getContext('2d');

setTimeout(() => {
    let gui = () => {
            if(!mouse_visible){
                ctx.beginPath();
                ctx.arc(x*2, y*2, 25, 0, 2 * Math.PI);
                ctx.fillStyle = "red";
                ctx.fill();
            }
            window.requestAnimationFrame(gui);
    }
    gui();
    setTimeout(() => {
        gui();
    },5000);
}, 1000);