Real Chat Overlay

Chat with your friends on local host

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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

})();