Skip to content

Instantly share code, notes, and snippets.

@Zemnmez
Created August 12, 2021 22:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zemnmez/c0566114430e25138a31a7a39758824e to your computer and use it in GitHub Desktop.
Save Zemnmez/c0566114430e25138a31a7a39758824e to your computer and use it in GitHub Desktop.
async function main() {
window.parent.postMessage("ready", "*");
const config = await new Promise((ok, fail) => {
console.log("waiting for config...")
window.addEventListener("message", ({ data }) => {
console.log("got config message");
if (data.type !== "config") return fail(`did not get config, instead got ${JSON.stringify(data)}`);
return ok(data);
}, { once: true })
});
console.log({ config });
console.log("now any data the null origin gets is sent to the icloud iframe...");
window.addEventListener("message", ({ data }) => {
console.log("forwarding to idmsa", data)
window.top.frames[config.idmsaFrameId].postMessage(data, "*");
});
}
main().catch(e => console.error(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment