OWoT online and offline

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

当前为 2023-01-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name OWoT online and offline
  3. // @namespace http://tampermonkey.net/
  4. // @version 1
  5. // @description Tells if someone goes online or offline (if they have this script).
  6. // @author e_g.
  7. // @match https://ourworldoftext.com/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. w.broadcastReceive(true);
  13. w.on('cmd', function(e){
  14. if(e.data.startsWith('online')){
  15. addChat(0, 0, 0, e.username, e.username + " is online!");
  16. }
  17. else if(e.data.startsWith('offline')){
  18. addChat(0, 0, 0, e.username, e.username + " is now offline.");
  19. };
  20. });
  21.  
  22. setTimeout(function(){
  23. w.broadcastCommand('online', true);
  24. }, 1000);
  25.  
  26. window.addEventListener('beforeunload', function(){
  27. w.broadcastCommand('offline', true)
  28. });