Can you shorten any of this code while doing the exact same thing? im looking for the most efficient way to do all of this. I have provided the full HTML script.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bot Detection</title>
    <script>
        let edge = false;

        const detectBot = () => {
            let isBot = 0;
            const resolutionsAndTolerances = [
                {resolution: [3840, 2160], toleranceWidth: 300, toleranceHeight: 250},
                {resolution: [2560, 1440], toleranceWidth: 300, toleranceHeight: 200},
                {resolution: [2048, 1440], toleranceWidth: 300, toleranceHeight: 300},
                {resolution: [1920, 1080], toleranceWidth: 250, toleranceHeight: 250},
                {resolution: [1000, 1000], toleranceWidth: 200, toleranceHeight: 200},
                {resolution: [1280, 720], toleranceWidth: 400, toleranceHeight: 200}
            ];

            if (!window.AudioContext || !navigator.mediaDevices) {
                isBot++;
                alert("Detected: Missing AudioContext or media devices");
            }
            for (let i = 0; i < resolutionsAndTolerances.length; i++) {
                const { resolution, tolerance } = resolutionsAndTolerances[i];
                const [width, height] = resolution;
                if (Math.abs(window.outerWidth - width) <= tolerance && Math.abs(window.outerHeight - height) <= tolerance) {
                    isBot++;
                }
            }
            if (navigator.languages === "") {
                isBot++;
                alert("Detected: No languages present");
            }
            if (window.chrome && window.chrome.webstore) {
                isBot++;
                alert("Detected: Chrome Web Store is accessible");
            }
            if (!navigator.plugins || navigator.plugins.length === 0) {
                isBot++;
                alert("Detected: No plugins found");
            }
            if (!navigator.mimeTypes || navigator.mimeTypes.length === 0) {
                isBot++;
                alert("Detected: No MIME types found");
            }
            if (edge != true && navigator.webdriver) {
                isBot++;
                alert("Detected: WebDriver is active");
            }
            const isFunctionTampered = fn => fn.toString().includes('[native code]') === false;
            var e = new Error();
            Object.defineProperty(e, "stack", {
                get() {
                    isBot++;
                    alert("Detected: Tampered stack trace");
                }
            });
            if (window.chrome && chrome.loadTimes && !chrome.csi) {
                isBot++;
                alert("Detected: Chrome load times present");
            }
            if (console.debug.toString().includes("puppeteer")) {
                isBot++;
                alert("Detected: Puppeteer in console.debug");
            }
            if (window.__nightmare || window.__puppeteer_evaluation_script) {
                isBot++;
                alert("Detected: Nightmare or Puppeteer evaluation script present");
            }
            if (window.open.toString().indexOf("native code") === -1) {
                isBot++;
                alert("Detected: window.open has been tampered");
            }
            const _0x5aa80b = Function.prototype.toString;
            Function.prototype.toString = function () {
                if (this === _0x5aa80b) {
                    isBot++;
                    alert("Detected: Bad Browser - Function.prototype.toString modified");
                    return "Bad Browser";
                }
                return _0x5aa80b.apply(this, arguments);
            };
            if ("__nightmare" in window || "__puppeteer" in window || "__chrome" in window) {
                isBot++;
                alert("Detected: Nightmare, Puppeteer, or Chrome object present");
            }
            const canvas = document.createElement("canvas");
            var gl = canvas.getContext("webgl");
            if (!gl) {
                isBot++;
                alert("Detected: WebGL context not available");
            }
            const gldbg = gl.getExtension("WEBGL_debug_render_info");
            if (gldbg) {
                var renderer = gl.getParameter(gldbg.UNMASKED_RENDERER_WEBGL);
                if (renderer.toLowerCase().includes("swiftshader") || renderer.toLowerCase().includes("google")) {
                    isBot++;
                    alert("Detected: SwiftShader/Google renderer in use");
                }
            }
            if (isFunctionTampered(HTMLElement.prototype.click)) {
                isBot++;
                alert("Detected: HTMLElement.prototype.click has been tampered");
            }
            return isBot;
        }

        const checkUserAgent = () => {
            const userAgent = navigator.userAgent.toLowerCase();
            return userAgent;
        };

        window.onload = () => {
            const userAgent = checkUserAgent();
            if (userAgent.includes("mozilla/5.0") && userAgent.includes("applewebkit/53") && userAgent.includes("chrome/131") && userAgent.includes("safari/537.36") && (userAgent.includes("edg/131") || userAgent.includes("edga/130"))) {
                edge = true;
            }
            const isBot = detectBot();
            if (isBot >= 1) {
                document.body.innerHTML = "<h1></h1>";
            } else {
                document.body.innerHTML = "<h1>No Bot Detected</h1>";
            }
        }
    </script>
    </head>
<body>
    <h1>Checking for Bots...</h1>
</body>
</html>


            }
            if (navigator.languages === "") {
                isBot++;
                alert("Detected: No languages present");
            }
            if (window.chrome && window.chrome.webstore) {
                isBot++;
                alert("Detected: Chrome Web Store is accessible");
            }
            if (!navigator.plugins || navigator.plugins.length === 0) {
                isBot++;
                alert("Detected: No plugins found");
            }
            if (!navigator.mimeTypes || navigator.mimeTypes.length === 0) {
                isBot++;
                alert("Detected: No MIME types found");
            }
            if (edge != true && navigator.webdriver) {
                isBot++;
                alert("Detected: WebDriver is active");
            }
            const isFunctionTampered = fn => fn.toString().includes('[native code]') === false;
            var e = new Error();
            Object.defineProperty(e, "stack", {
                get() {
                    isBot++;
                    alert("Detected: Tampered stack trace");
                }
            });
            if (window.chrome && chrome.loadTimes && !chrome.csi) {
                isBot++;
                alert("Detected: Chrome load times present");
            }
            if (console.debug.toString().includes("puppeteer")) {
                isBot++;
                alert("Detected: Puppeteer in console.debug");
            }
            if (window.__nightmare || window.__puppeteer_evaluation_script) {
                isBot++;
                alert("Detected: Nightmare or Puppeteer evaluation script present");
            }
            if (window.open.toString().indexOf("native code") === -1) {
                isBot++;
                alert("Detected: window.open has been tampered");
            }
            const _0x5aa80b = Function.prototype.toString;
            Function.prototype.toString = function () {
                if (this === _0x5aa80b) {
                    isBot++;
                    alert("Detected: Bad Browser - Function.prototype.toString modified");
                    return "Bad Browser";
                }
                return _0x5aa80b.apply(this, arguments);
            };
            if ("__nightmare" in window || "__puppeteer" in window || "__chrome" in window) {
                isBot++;
                alert("Detected: Nightmare, Puppeteer, or Chrome object present");
            }
            const canvas = document.createElement("canvas");
            var gl = canvas.getContext("webgl");
            if (!gl) {
                isBot++;
                alert("Detected: WebGL context not available");
            }
            const gldbg = gl.getExtension("WEBGL_debug_render_info");
            if (gldbg) {
                var renderer = gl.getParameter(gldbg.UNMASKED_RENDERER_WEBGL);
                if (renderer.toLowerCase().includes("swiftshader") || renderer.toLowerCase().includes("google")) {
                    isBot++;
                    alert("Detected: SwiftShader/Google renderer in use");
                }
            }
            if (isFunctionTampered(HTMLElement.prototype.click)) {
                isBot++;
                alert("Detected: HTMLElement.prototype.click has been tampered");
            }
            return isBot;
        }

        const checkUserAgent = () => {
            const userAgent = navigator.userAgent.toLowerCase();
            return userAgent;
        };

        window.onload = () => {
            const userAgent = checkUserAgent();
            if (userAgent.includes("mozilla/5.0") && userAgent.includes("applewebkit/53") && userAgent.includes("chrome/131") && userAgent.includes("safari/537.36") && (userAgent.includes("edg/131") || userAgent.includes("edga/130"))) {
                edge = true;
            }
            const isBot = detectBot();
            if (isBot >= 1) {
                document.body.innerHTML = "<h1></h1>";
            } else {
                document.body.innerHTML = "<h1>No Bot Detected</h1>";
            }
        }
    </script>