Open gregsadetsky opened 1 year ago
const TIME_LIMIT = 15 * 1000; /* 15 seconds */ const GET_RC_PAYLOAD = 'getRCPayload' const SDK_LOADED_START = 'sdkLoadedStart' const SDK_LOADED_END = 'sdkLoadedEnd' let timeoutID = null; window.onmessage = (event) => { const data = event.data; const iframe = event.source.window; switch (data.type) { case GET_RC_PAYLOAD: { iframe.postMessage({ type: 'RCPayload', payload: window.rcPayload }, '*'); break; } case SDK_LOADED_START: { timeoutID = setTimeout(() => { alert("HAHA SLOW COMPUTER MONKEY") // TODO: Go to the next iframe }, TIME_LIMIT) break; } case SDK_LOADED_END: { if (timeoutID) { clearTimeout(timeoutID) } break; } } }
(probably, approximately)