TupTest

Menu for SmarTest

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да инсталирате разширение, като например Tampermonkey .

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==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();
    }
})();