fix addEventListener

This commit is contained in:
velzie 2024-07-18 20:26:39 -04:00
parent 6a5ecc4efc
commit fd4bb03340
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
3 changed files with 29 additions and 5 deletions

View file

@ -1,6 +1,6 @@
window.postMessage = new Proxy(window.postMessage, {
apply(target, thisArg, argArray) {
if (typeof argArray[1] === "string") argArray[1] = "*"
if (typeof argArray[1] === "string") argArray[1] = "*";
Reflect.apply(target, thisArg, argArray);
}
},
});

View file

@ -77,3 +77,27 @@ export const documentProxy = new Proxy(document, {
return Reflect.set(target, prop, newValue);
},
});
Function.prototype.apply = new Proxy(Function.prototype.apply, {
apply(target, thisArg, argArray) {
if (argArray[0] === windowProxy) {
argArray[0] = window;
} else if (argArray[0] === documentProxy) {
argArray[0] = document;
}
return Reflect.apply(target, thisArg, argArray);
},
});
Function.prototype.call = new Proxy(Function.prototype.call, {
apply(target, thisArg, argArray) {
if (argArray[0] === windowProxy) {
argArray[0] = window;
} else if (argArray[0] === documentProxy) {
argArray[0] = document;
}
return Reflect.apply(target, thisArg, argArray);
},
});

View file

@ -17,7 +17,7 @@ initSync(
init();
Error.stackTraceLimit = 50
Error.stackTraceLimit = 50;
global.rws = rewriteJs;
export function rewriteJs(js: string | ArrayBuffer, origin?: URL) {