Elethor WebSocket override for window hook

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

目前为 2021-01-08 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Elethor 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.elethor.com/
  5. // @version 0.0.3
  6. // @author Anders Morgan Larsen (Xortrox)
  7. // @match https://elethor.com/
  8. // @match https://www.elethor.com/
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. const OldSocket = WebSocket;
  13.  
  14. window.WebSocket = function () {
  15. console.log('[WebSocket Hook] WebSocket hook successful.');
  16. const socket = new OldSocket(...arguments);
  17. window.socket = socket;
  18.  
  19. return socket;
  20. }