IQRPG - WebSocket override for window hook

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

目前为 2019-08-27 提交的版本。查看 最新版本

  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.1
  6. // @author Anders Morgan Larsen (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. function WebSocket() {
  17. const socket = new OldSocket(...arguments);
  18. window.socket = socket;
  19.  
  20. return socket;
  21. }