tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

claim-blob-url-worker-fetch-iframe.html (600B)


      1 <!doctype html>
      2 <script>
      3 const baseLocation = window.location;
      4 const workerScript =
      5  `self.onmessage = async (e) => {
      6    const url = new URL(e.data, '${baseLocation}').href;
      7    const response = await fetch(url);
      8    const text = await response.text();
      9    self.postMessage(text);
     10  };`;
     11 const blob = new Blob([workerScript], { type: 'text/javascript' });
     12 const blobUrl = URL.createObjectURL(blob);
     13 const worker = new Worker(blobUrl);
     14 
     15 function fetch_in_worker(url) {
     16  return new Promise((resolve) => {
     17    worker.onmessage = (e) => resolve(e.data);
     18    worker.postMessage(url);
     19  });
     20 }
     21 </script>