Real Chat Overlay

Chat with your friends on local host

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Real Chat Overlay
// @version      1.0
// @match        *://*/*
// @grant        none
// @namespace https://greasyfork.org/users/1594941
// @description Chat with your friends on local host
// ==/UserScript==

(function () {

    const ws = new WebSocket("ws://localhost:3000");

    const box = document.createElement("div");
    box.style = `
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 260px;
        height: 320px;
        background: rgba(0,0,0,0.85);
        color: white;
        z-index: 999999;
        font-family: Arial;
        display: flex;
        flex-direction: column;
        border-radius: 10px;
        padding: 8px;
    `;

    const log = document.createElement("div");
    log.style = `
        flex: 1;
        overflow-y: auto;
        font-size: 12px;
        margin-bottom: 6px;
    `;

    const input = document.createElement("input");
    input.placeholder = "Type message...";
    input.style = `
        padding: 6px;
        border: none;
        outline: none;
        border-radius: 5px;
    `;

    function addMsg(text) {
        const div = document.createElement("div");
        div.textContent = text;
        log.appendChild(div);
        log.scrollTop = log.scrollHeight;
    }

    ws.onmessage = (event) => {
        addMsg("Friend: " + event.data);
    };

    input.addEventListener("keydown", (e) => {
        if (e.key === "Enter" && input.value.trim()) {
            const msg = input.value;

            addMsg("You: " + msg);
            ws.send(msg);

            input.value = "";
        }
    });

    box.appendChild(log);
    box.appendChild(input);
    document.body.appendChild(box);

})();