tor-browser

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

redirects-target.html (1197B)


      1 <!doctype html>
      2 <title>Destination of a Redirect</title>
      3 <script src="stash.js"></script>
      4 <script>
      5 function checkScroll() {
      6  // Two rAFs since the exact timing of when we cause scrolling is up to the
      7  // UA.
      8  requestAnimationFrame(() => {
      9    requestAnimationFrame(() => {
     10      let twice = (new URL(document.location)).searchParams.get("twice");
     11      let key = (new URL(document.location)).searchParams.get("key");
     12      let results = {
     13        scrolled: (window.pageYOffset != 0),
     14      };
     15 
     16      if (twice != null) {
     17        // If this param is specified, we'll try to redirect to another
     18        // text-fragment after this one has been invoked.
     19        if (!results.scrolled) {
     20          results.scrolled = null;
     21          stashResultsThenClose(key, results);
     22          throw "Intermediate page failed to scroll to fragment";
     23        }
     24 
     25        window.location = `redirects-target2.html?key=${key}#:~:text=target`;
     26      } else {
     27        stashResultsThenClose(key, results);
     28      }
     29    });
     30  });
     31 }
     32 window.addEventListener('load', checkScroll);
     33 </script>
     34 <style>
     35  p#target {
     36    margin: 2000px 0px 2000px 0px;
     37  }
     38 </style>
     39 <body>
     40  <p>Top of page</p>
     41  <p id="target">target</p>
     42 </body>