mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 15:00:01 -04:00
feat: rewrite iframe.contentWindow
This commit is contained in:
parent
506d99f9b6
commit
93db66ebc8
2 changed files with 20 additions and 4 deletions
|
@ -48,13 +48,13 @@ export class ScramjetClient {
|
||||||
|
|
||||||
constructor(public global: typeof globalThis) {
|
constructor(public global: typeof globalThis) {
|
||||||
if ("document" in self) {
|
if ("document" in self) {
|
||||||
this.documentProxy = createDocumentProxy(this, self);
|
this.documentProxy = createDocumentProxy(this, global);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.locationProxy = createLocationProxy(this, self);
|
this.locationProxy = createLocationProxy(this, global);
|
||||||
this.windowProxy = createWindowProxy(this, self);
|
this.windowProxy = createWindowProxy(this, global);
|
||||||
|
|
||||||
self[ScramjetClient.SCRAMJET] = this;
|
global[ScramjetClient.SCRAMJET] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
hook() {
|
hook() {
|
||||||
|
|
|
@ -140,6 +140,22 @@ export default function (client: ScramjetClient, self: typeof window) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
client.Trap("HTMLIFrameElement.prototype.contentWindow", {
|
||||||
|
get(ctx) {
|
||||||
|
const realwin = ctx.get() as Window;
|
||||||
|
|
||||||
|
if (ScramjetClient.SCRAMJET in realwin.self) {
|
||||||
|
return realwin.self[ScramjetClient.SCRAMJET].windowProxy;
|
||||||
|
} else {
|
||||||
|
// hook the iframe
|
||||||
|
const newclient = new ScramjetClient(realwin.self);
|
||||||
|
newclient.hook();
|
||||||
|
|
||||||
|
return newclient.windowProxy;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
for (const target of [
|
for (const target of [
|
||||||
self.Node.prototype,
|
self.Node.prototype,
|
||||||
self.MutationObserver.prototype,
|
self.MutationObserver.prototype,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue