From 4ea3e74fb6e5f977a2ce95698933215429358e07 Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Sun, 27 Oct 2024 15:08:56 -0500 Subject: [PATCH] fix: only check for scramjetclient if win exists --- src/client/global.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/client/global.ts b/src/client/global.ts index 9c48417..eaf1e1c 100644 --- a/src/client/global.ts +++ b/src/client/global.ts @@ -36,20 +36,22 @@ export function createGlobalProxy( const win: Self = value.self; // indexing into window gives you the contentWindow of the subframes for some reason // you can't *set* it so this should always be the right value - if (SCRAMJETCLIENT in win) { - // then we've already hooked this frame and we can just send over its proxy - return win[SCRAMJETCLIENT].globalProxy; - } else { - // this can happen if it's an about:blank iframe that we've never gotten the chance to inject into - // just make a new client for it and inject - const newclient = new ScramjetClient(win); - newclient.hook(); + if (win) { + if (SCRAMJETCLIENT in win) { + // then we've already hooked this frame and we can just send over its proxy + return win[SCRAMJETCLIENT].globalProxy; + } else { + // this can happen if it's an about:blank iframe that we've never gotten the chance to inject into + // just make a new client for it and inject + const newclient = new ScramjetClient(win); + newclient.hook(); - return newclient.globalProxy; + return newclient.globalProxy; + } } } - if (prop === "$scramjet") return null; + if (prop === "$scramjet") return undefined; if (typeof prop === "string" && UNSAFE_GLOBALS.includes(prop)) return client.wrapfn(value);