Mobile Dev Console Toggle (Eruda) by Mohammed

Lightweight floating button to toggle Eruda console on any website (optimized for mobile browsers).

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Mobile Dev Console Toggle (Eruda) by Mohammed
// @namespace    https://github.com/MohammedBeshr0
// @version      1.0.0
// @description  Lightweight floating button to toggle Eruda console on any website (optimized for mobile browsers).
// @author       Mohammed
// @match        *://*/*
// @grant        none
// @run-at       document-end
// @license      MIT
// @homepageURL  https://greasyfork.org/
// @supportURL   https://greasyfork.org/
// ==/UserScript==

/*
 * This userscript dynamically loads Eruda (https://github.com/liriliri/eruda)
 * Eruda is an open-source console for mobile browsers.
 * Original library author: liriliri
 * License: MIT
 */

(function () {
    'use strict';

    let erudaLoaded = false;
    let erudaVisible = false;

    function loadEruda() {
        if (erudaLoaded) return;

        const script = document.createElement('script');
        script.src = "https://cdn.jsdelivr.net/npm/eruda";
        script.async = true;

        script.onload = function () {
            if (typeof eruda !== "undefined") {
                eruda.init({
                    defaults: {
                        displaySize: 50,
                        transparency: 1,
                        theme: 'Arc Dark'
                    }
                });
                erudaLoaded = true;
                erudaVisible = true;
            }
        };

        document.head.appendChild(script);
    }

    function toggleEruda() {
        if (!erudaLoaded) {
            loadEruda();
        } else {
            if (erudaVisible) {
                eruda.hide();
                erudaVisible = false;
            } else {
                eruda.show();
                erudaVisible = true;
            }
        }
    }

    function createButton() {
        const btn = document.createElement('div');
        btn.textContent = "DEV";

        Object.assign(btn.style, {
            position: "fixed",
            bottom: "20px",
            right: "20px",
            width: "55px",
            height: "55px",
            background: "#111",
            color: "#00ff88",
            display: "flex",
            alignItems: "center",
            justifyContent: "center",
            borderRadius: "50%",
            fontSize: "14px",
            fontWeight: "bold",
            zIndex: "2147483647",
            cursor: "pointer",
            boxShadow: "0 4px 12px rgba(0,0,0,0.4)",
            userSelect: "none"
        });

        btn.addEventListener("click", toggleEruda);
        document.documentElement.appendChild(btn);
    }

    if (document.readyState === "loading") {
        document.addEventListener("DOMContentLoaded", createButton);
    } else {
        createButton();
    }

})();