🥬 disconnect alerts 💸

auto reconnect if you disconnect from the socket, very easy to use

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

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

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!)

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.

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

// ==UserScript==
// @name         🥬 disconnect alerts 💸
// @namespace    http://tampermonkey.net/
// @version      1.0.1.1
// @description  auto reconnect if you disconnect from the socket, very easy to use
// @author       x/y codeing studios, zackiboiz for antiafk script
// @match        https://classic.talkomatic.co/room.html?roomId=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=talkomatic.co
// @grant        none
// @license      MIT
// ==/UserScript==

// We may switch to more autonomous methods in the future, to prevent complex configuration
// Change some of these depending on your WiFi speed if the program doesn't work as intended

var CONFIG = {
    ANTIAFK: true, // Default: true
    RUNTIME: 3000, // Default: 3.0 seconds
    CONNECT: 1500, // Default: 1.5 seconds
    RESTORE: 3000, // Default: 3.0 seconds
    WAITING: 1000, // Default: 1.0 seconds
}

// Helping function.
function uploadMessage (t) {
    if (!chatInput) { return } // Prevent the crash
    chatInput.textContent = t
    updateSentMessage() // Talkomatic function to emit the message
}
// Wait reasonable amount of time to run codes, default: 3 seconds
setTimeout(() => {
    // First we check if socket is already disconnected
    if (!socket.connected) {
        // We already disconnected. What a bummer
        window.location.reload()
    }
    // Then register callback
    socket.on("disconnect", (e) => {
        // Wait for determining if it's a reload, the thread freezes if reloading.
        setTimeout(() => {
            // Persist the last sent message to localStorage
            if (lastSentMessage) {
                localStorage.Message = lastSentMessage
            }
            setTimeout(() => {window.location.reload()}, CONFIG.CONNECT)
        }, CONFIG.WAITING)
    })
}, CONFIG.RUNTIME)

socket.on("connect", (e) => {
    // Oh good. We connection, we send the saved message
    if (localStorage.Message) {
        // If the message doesn't get restored, try increasing CONFIG.RESTORE
        setTimeout(() => {uploadMessage(localStorage.Message); localStorage.Message = ""}, CONFIG.RESTORE)
    }
})

if (CONFIG.ANTIAFK) {
    setInterval(() => {
        // If you emit socket event, server no kick you!
        socket.emit("anti-afk", {
            "sender": (currentUsername + " / " + currentLocation)
        })
    }, 10000)
}