mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 06:20:02 -04:00
fix addEventListener
This commit is contained in:
parent
6a5ecc4efc
commit
fd4bb03340
3 changed files with 29 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
window.postMessage = new Proxy(window.postMessage, {
|
window.postMessage = new Proxy(window.postMessage, {
|
||||||
apply(target, thisArg, argArray) {
|
apply(target, thisArg, argArray) {
|
||||||
if (typeof argArray[1] === "string") argArray[1] = "*"
|
if (typeof argArray[1] === "string") argArray[1] = "*";
|
||||||
Reflect.apply(target, thisArg, argArray);
|
Reflect.apply(target, thisArg, argArray);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -77,3 +77,27 @@ export const documentProxy = new Proxy(document, {
|
||||||
return Reflect.set(target, prop, newValue);
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
|
@ -17,7 +17,7 @@ initSync(
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
Error.stackTraceLimit = 50
|
Error.stackTraceLimit = 50;
|
||||||
|
|
||||||
global.rws = rewriteJs;
|
global.rws = rewriteJs;
|
||||||
export function rewriteJs(js: string | ArrayBuffer, origin?: URL) {
|
export function rewriteJs(js: string | ArrayBuffer, origin?: URL) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue