Geoguessr Tag

Provides a tag function that sends a message that is only visible to other scripts.

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://updategreasyfork.deno.dev/scripts/502813/1423193/Geoguessr%20Tag.js

  1. // ==UserScript==
  2. // @name Geoguessr Tag
  3. // @description Provides a tag function that sends a message that is only visible to other scripts.
  4. // @version 1.0.0
  5. // @author victheturtle#5159
  6. // @license MIT
  7. // @namespace https://gf.zukizuki.org/users/967692-victheturtle
  8. // ==/UserScript==
  9.  
  10. const prefix = "chat:InGame:TextMessages:";
  11.  
  12. let messageSocket = null;
  13. let accessToken = null;
  14. let lobbyId = null;
  15.  
  16. const originalSend = WebSocket.prototype.send;
  17. WebSocket.prototype.send = function(...args) {
  18. try {
  19. const json = JSON.parse(...args);
  20. if (json.topic?.startsWith(prefix)) {
  21. accessToken = json.accessToken || accessToken;
  22. messageSocket = this;
  23. lobbyId = json.topic.split(":")[3];
  24. }
  25. } catch(e) { }
  26. return originalSend.call(this, ...args);
  27. };
  28.  
  29. function tag(string) {
  30. if (!messageSocket || !accessToken || !lobbyId) return false;
  31. messageSocket.send(JSON.stringify({code: 'ChatMessage', topic: `${prefix}${lobbyId}:green`, payload: string, accessToken}));
  32. return true;
  33. }