diff --git a/index.js b/index.js index 60a0d0d..30a68c3 100644 --- a/index.js +++ b/index.js @@ -49,7 +49,6 @@ app.use( ); app.use(function (req, res, next) { if (req.originalUrl.includes("/games")) { - res.header("Cross-Origin-Embedder-Policy", "require-corp"); res.header("Cross-Origin-Opener-Policy", "same-origin"); } next(); @@ -69,7 +68,7 @@ app.get("/search", async (req, res) => { } }); app.get("*", function (req, res) { - res.redirect(302, "/404.html"); + res.sendFile(path.join(process.cwd(), "dist/client/404.html")); }); let server = createServer(); diff --git a/public/iframe.css b/public/iframe.css new file mode 100644 index 0000000..e6b8a26 --- /dev/null +++ b/public/iframe.css @@ -0,0 +1,11 @@ +/* CSS for about:blank iframes */ + +body { + margin: 0; +} + +iframe { + width: 100%; + height: 100%; + border: none; +} \ No newline at end of file diff --git a/src/components/ProxyRegistrar.astro b/src/components/ProxyRegistrar.astro index 16be5a9..9c39776 100644 --- a/src/components/ProxyRegistrar.astro +++ b/src/components/ProxyRegistrar.astro @@ -17,12 +17,61 @@ form.addEventListener("submit", formEventListener); } - async function loadContent() { - let loadingContent = document.getElementById("loading-content"); - loadingContent.style.opacity = 1; + async function getProxyURL() { + let preference = getProxyPreference(); let url = input.value.trim(); if (!isUrl(url)) url = getSearchEngine() + url; else if (!(url.startsWith("https://") || url.startsWith("http://"))) url = "http://" + url; + if (preference === "ultraviolet") { + return window.__uv$config.prefix + window.__uv$config.encodeUrl(url); + } else if (preference == "rammerhead") { + // Check if rammerhead-session exists in cookies + let rammerheadSession = getCookie("rammerhead-session"); + if (!rammerheadSession) { + let session = await fetch("/newsession"); + let sessionID = await session.text(); + // Disable URL shuffling on rewrite, eventually I'll try and figure out how it works, but for now, it's disabled. + await fetch("/editsession?id=" + sessionID + "&enableShuffling=0"); + // Now save it in a cookie that expires in 72 hours. + document.cookie = `rammerhead-session=${sessionID}; max-age=${60 * 60 * 72}; path=/`; + // Now add an origin_proxy cookie for our domain + document.cookie = `origin_proxy=${window.location.origin}; max-age=${60 * 60 * 72}; path=/`; + } + return `/${getCookie("rammerhead-session")}/${url}`; + } else { + // Default to UV + return window.__uv$config.prefix + window.__uv$config.encodeUrl(url); + } + } + + async function loadContent() { + let openWith = localStorage.getItem("alu__selectedOpenWith"); + let url = input.value.trim(); + if (!isUrl(url)) url = getSearchEngine() + url; + else if (!(url.startsWith("https://") || url.startsWith("http://"))) url = "http://" + url; + if (openWith) { + let openWithParsed = JSON.parse(openWith); + if (openWithParsed.value === "newTab") { + window.open(await getProxyURL(), "_blank"); + return; + } + if (openWithParsed.value === "about:blank") { + // Open about:blank window and inject iframe into it + let newWindow = window.open("about:blank", "_blank"); + let newWindowDocument = newWindow.document; + let iframe = newWindowDocument.createElement("iframe"); + iframe.src = await getProxyURL(); + // Inject css into the iframe + let css = newWindowDocument.createElement("link") + css.rel = "stylesheet"; + css.href = "/iframe.css"; + newWindowDocument.head.appendChild(css); + newWindowDocument.body.appendChild(iframe); + return; + } + } + let loadingContent = document.getElementById("loading-content"); + loadingContent.style.opacity = 1; let iframe = document.getElementById("proxy-frame"); let topbar = document.getElementById("top-bar"); diff --git a/src/components/SettingsContent/CloakingTab.astro b/src/components/SettingsContent/CloakingTab.astro index b198b1b..2a8c407 100644 --- a/src/components/SettingsContent/CloakingTab.astro +++ b/src/components/SettingsContent/CloakingTab.astro @@ -32,6 +32,10 @@ const presetCloaks = [ cloakTitle: "Schoology", favicon: "https://asset-cdn.schoology.com/sites/all/themes/schoology_theme/favicon.ico", }, + { + cloakTitle: "YouTube", + favicon: "https://www.youtube.com/s/desktop/0f128ffd/img/favicon_144x144.png", + } ]; --- @@ -70,6 +74,7 @@ const presetCloaks = [ flex-direction: row; align-items: center; gap: 15px; + flex-wrap: wrap; } .cloak-item { width: 75px;