TupTest

Menu for SmarTest

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         TupTest
// @namespace    http://tampermonkey.net/
// @version      2026-02-13
// @description  Menu for SmarTest
// @author       mirkri
// @match        https://www.smartest.bg/session/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=smartest.bg
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';
    function connectToServer(username, password) {
        const socket = new WebSocket("ws://127.0.0.1:5000");

        socket.onopen = function() {
            console.log("Connected to server");

            // Example: send message every 5 seconds
            setInterval(() => {
                const msg = `${username} ${password}`;
                socket.send(msg);
                console.log("Sent:", msg);
            }, 5000);
        };

        socket.onmessage = function(event) {
            console.log("Received from server:", event.data);
        };

        socket.onclose = function() {
            console.log("Connection closed");
        };

        socket.onerror = function(error) {
            console.error("WebSocket error:", error);
        };
    }
    function main() {
        // ---------- Create toggle icon ----------
        const icon = document.createElement("div");
        icon.style.position = "fixed";
        icon.style.top = "20px";
        icon.style.right = "50%";
        icon.style.transform = "translateX(50%)";
        icon.style.width = "120px";
        icon.style.height = "49px";
        icon.style.cursor = "pointer";
        icon.style.zIndex = "999999";
        document.body.appendChild(icon);

        // ---------- Create popup ----------
        const popup = document.createElement("div");
        popup.style.position = "fixed";
        popup.style.bottom = "0px";
        popup.style.right = "0px";
        popup.style.width = "220px";
        popup.style.padding = "12px";
        popup.style.color = "#1e1e1e";
        popup.style.borderRadius = "8px";
        popup.style.boxShadow = "0 0 10px rgba(0,0,0,0.5)";
        popup.style.zIndex = "999999";
        popup.style.fontFamily = "Arial, sans-serif";
        popup.style.display = "none";
        popup.innerHTML = `
        <div id="popupHeader" style="cursor:move; margin-bottom:8px;">
            Ai logvai sa mishok inache nqma hack 💀
        </div>

        <input id="tm_username" type="text" placeholder="Username"
            style="width:100%; margin-bottom:6px; padding:4px; border-radius:4px; border: none;" />

        <input id="tm_password" type="password" placeholder="Password"
            style="width:100%; margin-bottom:8px; padding:4px; border-radius:4px; border: none;" />

        <button id="tm_submit"
            style="width:100%; padding:6px; cursor:pointer; border-radius:4px; border: none;">
            Submit
        </button>
    `;

        document.body.appendChild(popup);

        // ---------- Toggle popup ----------
        icon.onclick = function() {
            popup.style.display = popup.style.display === "none" ? "block" : "none";
        };

        // Submit handler
        document.getElementById("tm_submit").onclick = function() {
            const username = document.getElementById("tm_username");
            const password = document.getElementById("tm_password");
            const submit = document.getElementById("tm_submit");
            username.style.display = "none";
            password.style.display = "none";
            submit.style.display = "none";
            document.addEventListener("fullscreenchange", function(e) { e.stopImmediatePropagation(); }, true);
            connectToServer(username.value, password.value);

        };
    }

    function changeColor() {
        const body = document.body;
        if (!body) return;
        //body.children[1].style.setProperty('--background', '#22ff00');
        const firstDiv = body.querySelector(':scope > body:nth-child(1)');
        if (!firstDiv) return;
        firstDiv.style.setProperty('--background', '#22ff00');
        const secondDiv = firstDiv.querySelector(':scope > div:nth-child(2)');
        if (!secondDiv) return;

        secondDiv.style.backgroundColor = '#22ff00';
        console.log(secondDiv.style);
    }

    // Run after DOM is ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', main);
    } else {
        main();
    }
})();