Skip to content

Commit

Permalink
fix: only check for scramjetclient if win exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Oct 27, 2024
1 parent 1b509b2 commit 4ea3e74
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/client/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4ea3e74

Please sign in to comment.