From d911e4b797840ee9c2cf2321738e7aa88bafa35a Mon Sep 17 00:00:00 2001 From: nvd123YT <78279767+WatchGamingVideos@users.noreply.github.com> Date: Mon, 20 May 2024 09:20:22 -0400 Subject: [PATCH] tabs update 2 --- static/assets/scripts/ta.js | 39 ++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/static/assets/scripts/ta.js b/static/assets/scripts/ta.js index 50cabf422..10173ae58 100644 --- a/static/assets/scripts/ta.js +++ b/static/assets/scripts/ta.js @@ -1,8 +1,5 @@ - window.addEventListener("load", () => { - navigator.serviceWorker.register("../sw.js?v=5-5-2024", { - scope: "/a/", - }) + navigator.serviceWorker.register("../sw.js?v=5-5-2024", { scope: "/a/" }) }) window.addEventListener("load", () => { const form = document.getElementById("fs") @@ -50,6 +47,7 @@ document.addEventListener("DOMContentLoaded", function (event) { const newTab = document.createElement("li") const tabTitle = document.createElement("span") const newIframe = document.createElement("iframe") + newIframe.sandbox = "allow-same-origin allow-scripts allow-forms" tabTitle.textContent = `New Tab ${tabCounter}` tabTitle.className = "tab-title" newTab.dataset.tabId = tabCounter @@ -72,16 +70,22 @@ document.addEventListener("DOMContentLoaded", function (event) { newIframe.addEventListener("load", () => { const title = newIframe.contentDocument.title if (title.length <= 1) { - tabTitle.textContent = "New Tab" + tabTitle.textContent = "" } else { tabTitle.textContent = title } + newIframe.contentWindow.open = function (url) { + sessionStorage.setItem("URL", "/a/" + __uv$config.encodeUrl(url)) + createNewTab() + return null + } if (newIframe.contentDocument.documentElement.outerHTML.trim().length > 0) { Load() } Load() }) const GoURL = sessionStorage.getItem("GoUrl") + const URL = sessionStorage.getItem("URL") if (tabCounter === 1) { if (GoURL !== null) { @@ -93,9 +97,23 @@ document.addEventListener("DOMContentLoaded", function (event) { } else { newIframe.src = "/" } - } else { - newIframe.src = "/" + } else if (tabCounter > 1) { + if (URL !== null) { + newIframe.src = window.location.origin + URL + sessionStorage.removeItem("URL") + } else if (GoURL !== null) { + if (GoURL.includes("/e/")) { + newIframe.src = window.location.origin + GoURL + sessionStorage.removeItem("GoUrl") + } else { + newIframe.src = window.location.origin + "/a/" + GoURL + sessionStorage.removeItem("GoUrl") + } + } else { + newIframe.src = "/" + } } + iframeContainer.appendChild(newIframe) tabCounter += 1 } @@ -288,10 +306,10 @@ function goForward() { } // Remove Nav document.addEventListener("DOMContentLoaded", function () { - var TB = document.getElementById("tabs-button") - var NB = document.getElementById("right-side-nav") + const TB = document.getElementById("tabs-button") + const NB = document.getElementById("right-side-nav") TB.addEventListener("click", function () { - var activeIframe = document.querySelector("#iframe-container iframe.active") + const activeIframe = document.querySelector("#iframe-container iframe.active") if (NB.style.display === "none") { NB.style.display = "" activeIframe.style.top = "10%" @@ -336,7 +354,6 @@ function decodeXor(input) { return input } let [str, ...search] = input.split("?") - return ( decodeURIComponent(str) .split("")