mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
postmessage handler
This commit is contained in:
parent
bcbb660cc6
commit
73c1c8a5c8
4 changed files with 12 additions and 6 deletions
|
@ -8,3 +8,8 @@
|
|||
// return Reflect.apply(target, thisArg, argArray);
|
||||
// }
|
||||
// })
|
||||
// window.addEventListener = new Proxy(window.addEventListener, {
|
||||
// apply(target1, thisArg, argArray) {
|
||||
// window.addEventListener(argArray[0], argArray[1]);
|
||||
// },
|
||||
// });
|
||||
|
|
|
@ -15,6 +15,7 @@ import "./worker.ts";
|
|||
import "./beacon.ts";
|
||||
import "./origin.ts";
|
||||
import "./import.ts";
|
||||
import "./postmessage.ts";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
|
|
6
src/client/postmessage.ts
Normal file
6
src/client/postmessage.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
window.postMessage = new Proxy(window.postMessage, {
|
||||
apply(target, thisArg, argArray) {
|
||||
if (typeof argArray[1] === "string") argArray[1] = "*"
|
||||
Reflect.apply(target, thisArg, argArray);
|
||||
}
|
||||
});
|
|
@ -15,12 +15,6 @@ export const windowProxy = new Proxy(window, {
|
|||
return window.parent;
|
||||
} else if (propIsString && prop === "$scramjet") {
|
||||
return;
|
||||
} else if (propIsString && prop === "addEventListener") {
|
||||
return new Proxy(window.addEventListener, {
|
||||
apply(target1, thisArg, argArray) {
|
||||
window.addEventListener(argArray[0], argArray[1]);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const value = Reflect.get(target, prop);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue