tor-browser

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

window-name.sub.html (2430B)


      1 <!doctype html>
      2 <title>popup helper</title>
      3 <script>
      4 
      5 const search = decodeURIComponent(window.location.search.replace("?", ""));
      6 const steps = search.split("|");
      7 
      8 async function proceedTest() {
      9  while (steps.length) {
     10    const step = steps.shift();
     11 
     12    if (step.startsWith("report=")) {
     13      const id = step.split("=")[1];
     14      const stashURL = new URL("window-name-stash.py", location);
     15      stashURL.searchParams.set('id', id);
     16      stashURL.searchParams.set('value', window.name);
     17 
     18      await fetch(stashURL, { method: "POST" });
     19      continue;
     20    }
     21 
     22    if (step === "close") {
     23      window.close();
     24      break;
     25    }
     26 
     27    if (step === "cross") {
     28      const url = new URL(window.location);
     29      url.host = "{{hosts[alt][]}}:{{ports[https][0]}}";
     30      url.search = "?" + steps.join("|");
     31      window.location = url.href;
     32      break;
     33    }
     34 
     35    if (step === "same") {
     36      const url = new URL(window.location);
     37      url.host = "{{host}}:{{ports[https][0]}}";
     38      url.search = "?" + steps.join("|");
     39      window.location = url.href;
     40      break;
     41    }
     42 
     43    if (step === "sub") {
     44      const url = new URL(window.location);
     45      url.host = "{{hosts[][www]}}:{{ports[https][0]}}";
     46      url.search = "?" + steps.join("|");
     47      window.location = url.href;
     48      break;
     49    }
     50 
     51    if (step === "closeOpener") {
     52      if (window.opener) {
     53        window.opener.close();
     54      }
     55      continue;
     56    }
     57 
     58    if (step.startsWith("navOpener=")) {
     59      if (!window.opener) {
     60        continue;
     61      }
     62 
     63      let url = step.split("=")[1];
     64      window.opener.location.href = url;
     65 
     66      continue;
     67    }
     68 
     69    if (step === "open") {
     70      const url = new URL(window.location);
     71      url.host = "{{host}}:{{ports[https][0]}}";
     72      url.search = "?" + steps.join("|");
     73      window.open(url);
     74      break;
     75    }
     76 
     77    if (step.startsWith("reportOpener=")) {
     78      const id = step.split("=")[1];
     79      const stashURL = new URL("window-name-stash.py", location);
     80      stashURL.searchParams.set('id', id);
     81      stashURL.searchParams.set('value', window.opener.name);
     82 
     83      await fetch(stashURL, { method: "POST" });
     84      continue;
     85    }
     86 
     87    if (step.startsWith("set=")) {
     88      window.name = step.split("=")[1];
     89      continue;
     90    }
     91 
     92    if (step.startsWith("setDomain=")) {
     93      document.domain = step.split("=")[1];
     94      continue;
     95    }
     96 
     97    throw new Error("Unsupported step!");
     98  }
     99 }
    100 
    101 proceedTest();
    102 </script>