FoV Script

A FoV script for the Diep.io game.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey 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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         FoV Script
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  A FoV script for the Diep.io game.
// @author       Altanis
// @match        *://diep.io/*
// @match        *://diep-io.rivet.game/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    /**
    NOTE: This will only work on the first server you connect to.
    If you connect to a different server, this script will no longer work (and may even crash the game).
    To use this script in a different server, reload.
    */

    const handler = {apply(r,o,args){Error.stackTraceLimit=0;return r.apply(o,args)}};Object.freeze = new Proxy(Object.freeze, handler)

    window.HEAPF32 = undefined;
    window.fov = [];

    const win = typeof unsafeWindow != "undefined" ? unsafeWindow : window;
    win.Object.defineProperty(win.Object.prototype, "HEAPF32", {
        get: function() {
            return undefined;
        },
        set: function(to) {
            if(!to || !this.HEAPU32) return;
            delete win.Object.prototype.HEAPF32;
            window.Module = this;
            window.Module.HEAPF32 = to;
            window.HEAPF32 = to;

            console.log("HEAPF32 found");
        },
        configurable: true,
        enumerable: true
    });


    const int = setInterval(function() {
        if (!document.querySelector('#home-screen[x-state="awaiting-spawn"] > #spawn-input > #pre-spawn-text')) return;
        Array.from(window.HEAPF32).map((val, index) => {
            if (val === 0.3499999940395355) { // 0.550000011920929
                window.fov.push(index);
                console.log('Got index', index);
            }
        });
        clearInterval(int);
    }, 150);

    document.addEventListener('keydown', async event => {
        if (event.key == '-') {
            console.log('Zooming out...');
            for (const fov of window.fov) {
                window.HEAPF32[fov] -= 0.1;
            }
        } else if (event.key == '+') {
            console.log('Zooming in...');
            for (const fov of window.fov) {
                window.HEAPF32[fov] += 0.1;
            }
        }
    });
})();