Advertisement
mattygh

Untitled

May 17th, 2022
543
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const nativeWebSocket = window.WebSocket;
  2. var socketInterceptor;
  3. window.WebSocket = (...args) => {
  4.     console.log("Called websocket initialization");
  5.     socketInterceptor = new nativeWebSocket(args);
  6.     socketInterceptor.addEventListener('message', (event) => {
  7.         console.log("message", event);
  8.     });
  9.     socketInterceptor.addEventListener('open', (event) => {
  10.         console.log("opened", event);
  11.     });
  12.     return socketInterceptor;
  13. }
  14. webFrame.executeJavaScript(`
  15. delete window.WebSocket;
  16. `);
  17. contextBridge.exposeInMainWorld("WebSocket", window.WebSocket);
Advertisement
RAW Paste Data Copied
Advertisement