🥬 disconnect alerts 💸

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

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

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