OWoT online and offline

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

目前为 2023-03-09 提交的版本。查看 最新版本

// ==UserScript==
// @name         OWoT online and offline
// @namespace    https://gf.qytechs.cn/scripts/458537-owot-online-and-offline
// @version      7.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==

let warn = true;
let counter = 0;

menu.addCheckboxOption('Online Offline warning', function(){
    warn = true;
}, function(){
    warn = false;
}, true);

w.broadcastReceive(true);
w.on('cmd', function(e){
    if(!e.username || !warn) return;
    if(e.data.startsWith('online')){
        clientChatResponse(e.username + " is online!");
    }
    else if(e.data.startsWith('offline')){
        clientChatResponse(e.username + " is now offline.");
    }
    else if(e.data.startsWith('back')){
        clientChatResponse(e.username + " is back.");
    }
    else if(e.data.startsWith('afk')){
        clientChatResponse(e.username + " is AFK. (Idle)");
    }
    else if(e.data.startsWith('typing')){
        w.doAnnounce(e.username + " is typing...");
    }
    else if(e.data.startsWith('untyping')){
        document.getElementsByClassName("announce_close")[0].click();
    };
});

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

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

window.onblur = function(){w.broadcastCommand('afk', true)};

window.onfocus = function(){w.broadcastCommand('back', true)};

elm.chatbar.oninput = function(){
    counter = 0;
};

setInterval(function(){
    if(elm.chatbar.value.length && counter < 5000) w.broadcastCommand('typing', true);
    counter += 100;
    if(counter >= 5000) w.broadcastCommand('untyping', true);
}, 100);

w.on("chatmod", function(e){
    if(e.realUsername == state.userModel.username) w.broadcastCommand('untyping', true);
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址