tor-browser

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

browser_autoplay_blocked_slow.sjs (846B)


      1 /* Any copyright is dedicated to the Public Domain.
      2  * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 const DELAY_MS = 200;
      5 
      6 const AUTOPLAY_HTML = `<!DOCTYPE HTML>
      7 <html dir="ltr" xml:lang="en-US" lang="en-US">
      8   <head>
      9     <meta charset="utf8">
     10   </head>
     11   <body>
     12     <audio autoplay="autoplay" >
     13       <source src="audio.ogg" />
     14     </audio>
     15     <script>
     16       document.location.href = '#foo';
     17     </script>
     18   </body>
     19 </html>`;
     20 
     21 function handleRequest(req, resp) {
     22   resp.processAsync();
     23   resp.setHeader("Cache-Control", "no-cache", false);
     24   resp.setHeader("Content-Type", "text/html;charset=utf-8", false);
     25 
     26   let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
     27   resp.write(AUTOPLAY_HTML);
     28   timer.init(
     29     () => {
     30       resp.write("");
     31       resp.finish();
     32     },
     33     DELAY_MS,
     34     Ci.nsITimer.TYPE_ONE_SHOT
     35   );
     36 }