mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 23:10: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 {
|
||||
encodeUrl,
|
||||
|
@ -138,10 +139,19 @@ MutationObserver.prototype.observe = new Proxy(
|
|||
}
|
||||
);
|
||||
|
||||
document.createTreeWalker = new Proxy(document.createTreeWalker, {
|
||||
apply(target, thisArg, argArray) {
|
||||
if (argArray[0] === documentProxy) argArray[0] = document;
|
||||
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
for (const target of [Node.prototype, document]) {
|
||||
for (const prop in target) {
|
||||
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) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue