tor-browser

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

keepalive-iframe.html (923B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <script>
      5 const SEARCH_PARAMS = new URL(location.href).searchParams;
      6 const ORIGIN = SEARCH_PARAMS.get('origin') || '';
      7 const FRAME_ORIGIN = new URL(location.href).origin;
      8 const TOKEN = SEARCH_PARAMS.get('token') || '';
      9 const METHOD = SEARCH_PARAMS.get('method') || 'GET';
     10 const SEND_ON_EVENT = SEARCH_PARAMS.get('sendOn') || 'load';
     11 const MODE = SEARCH_PARAMS.get('mode') || 'cors';
     12 const DISALLOW_CROSS_ORIGIN = SEARCH_PARAMS.get('disallowCrossOrigin') || '';
     13 // CORS requests are allowed by this URL by default.
     14 const url = `${ORIGIN}/fetch/api/resources/stash-put.py?key=${TOKEN}&value=on&mode=${MODE}`
     15    + `&frame_origin=${FRAME_ORIGIN}` + (DISALLOW_CROSS_ORIGIN ? `&disallow_cross_origin=1` : '');
     16 
     17 addEventListener(SEND_ON_EVENT, () => {
     18  let p = fetch(url, {keepalive: true, method: METHOD, mode: MODE});
     19  window.parent.postMessage(TOKEN, '*');
     20 });
     21 </script>
     22 </html>