mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
proxy for window[0]
This commit is contained in:
parent
490d4c96f5
commit
e942f5549e
1 changed files with 24 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
||||||
// import { encodeUrl } from "../shared";
|
// import { encodeUrl } from "../shared";
|
||||||
|
import { iswindow } from ".";
|
||||||
|
import { SCRAMJETCLIENT } from "../symbols";
|
||||||
import { ScramjetClient } from "./client";
|
import { ScramjetClient } from "./client";
|
||||||
// import { config } from "../shared";
|
// import { config } from "../shared";
|
||||||
import { getOwnPropertyDescriptorHandler } from "./helpers";
|
import { getOwnPropertyDescriptorHandler } from "./helpers";
|
||||||
|
@ -25,6 +27,28 @@ export function createGlobalProxy(
|
||||||
get(target, prop) {
|
get(target, prop) {
|
||||||
const value = Reflect.get(target, prop);
|
const value = Reflect.get(target, prop);
|
||||||
|
|
||||||
|
if (
|
||||||
|
iswindow &&
|
||||||
|
(typeof prop === "string" || typeof prop === "number") &&
|
||||||
|
!isNaN(Number(prop)) &&
|
||||||
|
value
|
||||||
|
) {
|
||||||
|
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();
|
||||||
|
|
||||||
|
return newclient.globalProxy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof prop === "string" && UNSAFE_GLOBALS.includes(prop))
|
if (typeof prop === "string" && UNSAFE_GLOBALS.includes(prop))
|
||||||
return client.wrapfn(value);
|
return client.wrapfn(value);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue