tor-browser

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

highRiskErrorPages.js (1517B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 /* eslint-disable no-unsanitized/property */ /* bug 1889942 */
      6 
      7 /**
      8 * Handles the parsing of the ErrorPages URI and then passes them to injectValues
      9 */
     10 function parseQuery(queryString) {
     11  if (queryString[0] === "?") {
     12    queryString = queryString.substr(1);
     13  }
     14  const query = Object.fromEntries(new URLSearchParams(queryString).entries());
     15  injectValues(query);
     16 }
     17 
     18 /**
     19 * Updates the HTML elements based on the queryMap
     20 */
     21 function injectValues(queryMap) {
     22  // Go through each element and inject the values
     23  document.title = queryMap.title;
     24  document.getElementById("errorTitleText").innerHTML = queryMap.title;
     25  document.getElementById("errorShortDesc").innerHTML = queryMap.description;
     26 
     27  // If no image is passed in, remove the element so as not to leave an empty iframe
     28  const errorImage = document.getElementById("errorImage");
     29  if (!queryMap.image) {
     30    errorImage.remove();
     31  } else {
     32    errorImage.src = "resource://android/assets/" + queryMap.image;
     33  }
     34 }
     35 
     36 document.addEventListener("DOMContentLoaded", function () {
     37  if (window.history.length == 1) {
     38    document.getElementById("backButton").style.display = "none";
     39  } else {
     40    document
     41      .getElementById("backButton")
     42      .addEventListener("click", () => window.history.back());
     43  }
     44 });
     45 
     46 parseQuery(document.documentURI);