1 2 3 4 5 6 7 8 9
<script> const params = new URLSearchParams(location.search); const worker = new SharedWorker(params.get('worker_url')); const onmessage_promise = new Promise(r => worker.port.onmessage = r); async function waitForMessage() { const message = await onmessage_promise; return message.data; } </script>