Greasy Fork is available in English.

IQRPG - WebSocket override for window hook

Overrides the WebSocket class and hooks any new instance of a WebSocket to a window.socket reference

  1. // ==UserScript==
  2. // @name IQRPG - WebSocket override for window hook
  3. // @description Overrides the WebSocket class and hooks any new instance of a WebSocket to a window.socket reference
  4. // @namespace https://www.iqrpg.com/
  5. // @version 0.0.2
  6. // @author Xortrox
  7. // @match http://www.iqrpg.com/game.php
  8. // @match https://www.iqrpg.com/game.php
  9. // @match https://iqrpg.com/game.php
  10. // @match http://iqrpg.com/game.php
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. const OldSocket = WebSocket;
  15.  
  16. window.WebSocket = function () {
  17. const socket = new OldSocket(...arguments);
  18. window.socket = socket;
  19.  
  20. return socket;
  21. }