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 4
  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. let warn = true;
  13.  
  14. menu.addCheckboxOption('Online Offline warning', function(){
  15. warn = true;
  16. }, function(){
  17. warn = false;
  18. }, true);
  19.  
  20. w.broadcastReceive(true);
  21. w.on('cmd', function(e){
  22. if(!e.username || !warn) return;
  23. if(e.data.startsWith('online')){
  24. clientChatResponse(e.username + " is online!");
  25. }
  26. else if(e.data.startsWith('offline')){
  27. clientChatResponse(e.username + " is now offline.");
  28. };
  29. });
  30.  
  31. setTimeout(function(){
  32. w.broadcastCommand('online', true);
  33. }, 1000);
  34.  
  35. window.addEventListener('beforeunload', function(){
  36. w.broadcastCommand('offline', true)
  37. });