uweb/en/searchurl/globaljs/websocket.js

14 lines
408 B
JavaScript
Raw Normal View History

2024-03-17 02:36:18 +00:00
window.WebSocketOriginal = window.WebSocket;
(function () {
function CustomWebSocket(url) {
const ws = new window.WebSocketOriginal(url);
Object.getOwnPropertyNames(window.WebSocket.prototype).forEach(methodName => {
if (methodName !== 'constructor') {
CustomWebSocket.prototype[methodName] = ws[methodName].bind(ws);
}
});
}
window.WebSocket = CustomWebSocket;
})();
t