OWoT online and offline

Tells if someone goes online or offline (if they have this script).

Pada tanggal 19 Januari 2023. Lihat %(latest_version_link).

// ==UserScript==
// @name         OWoT online and offline
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Tells if someone goes online or offline (if they have this script).
// @author       e_g.
// @match        https://ourworldoftext.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

w.broadcastReceive(true);
w.on('cmd', function(e){
    if(e.data.startsWith('online')){
        addChat(0, 0, 0, e.username, e.username + " is online!");
    }
    else if(e.data.startsWith('offline')){
        addChat(0, 0, 0, e.username, e.username + " is now offline.");
    };
});

setTimeout(function(){
    w.broadcastCommand('online', true);
}, 1000);

window.addEventListener('beforeunload', function(){
    w.broadcastCommand('offline', true)
});