mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-15 07:20:02 -04:00
hide document proxy from dom apis
This commit is contained in:
parent
e45e10edc7
commit
084f2cd789
1 changed files with 16 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import { client } from ".";
|
||||||
import { decodeUrl } from "../shared/rewriters/url";
|
import { decodeUrl } from "../shared/rewriters/url";
|
||||||
import {
|
import {
|
||||||
encodeUrl,
|
encodeUrl,
|
||||||
|
@ -138,10 +139,19 @@ MutationObserver.prototype.observe = new Proxy(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
document.createTreeWalker = new Proxy(document.createTreeWalker, {
|
for (const target of [Node.prototype, document]) {
|
||||||
apply(target, thisArg, argArray) {
|
for (const prop in target) {
|
||||||
if (argArray[0] === documentProxy) argArray[0] = document;
|
try {
|
||||||
|
if (typeof target[prop] === "function") {
|
||||||
|
client.Proxy(target, prop, {
|
||||||
|
apply(ctx) {
|
||||||
|
for (const i in ctx.args) {
|
||||||
|
if (ctx.args[i] === documentProxy) ctx.args[i] = document;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Reflect.apply(target, thisArg, argArray);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue