fix: websocket prototype

This commit is contained in:
Percs 2024-11-26 17:03:18 -06:00
parent 51f1a773a4
commit 58fed66f78
5 changed files with 221 additions and 222 deletions

View file

@ -6,11 +6,8 @@ export const enabled = (client: ScramjetClient) =>
export function argdbg(arg, recurse = []) {
switch (typeof arg) {
case "string":
if (arg.includes("localhost:1337/scramjet/") && arg.includes("m3u8"))
debugger;
break;
case "object":
// if (arg instanceof Location) debugger;
if (
arg &&
arg[Symbol.iterator] &&

View file

@ -21,7 +21,7 @@ export default function (client: ScramjetClient, self: typeof globalThis) {
client.Proxy("WebSocket", {
construct(ctx) {
const fakeWebSocket = new EventTarget() as WebSocket;
Object.setPrototypeOf(fakeWebSocket, self.WebSocket.prototype);
Object.setPrototypeOf(fakeWebSocket, ctx.fn.prototype);
fakeWebSocket.constructor = ctx.fn;
const trustEvent = (ev: Event) =>