From f8b92dc0b989ba4742562c385e63b5e7782489ed Mon Sep 17 00:00:00 2001 From: wearrrrr Date: Fri, 1 Mar 2024 22:48:04 -0600 Subject: [PATCH] Shows favicon when page is loaded in embed mode now. --- index.js | 3 +++ public/favicon.svg | 1 - public/games | 2 +- src/components/ProxyRegistrar.astro | 21 +++++++++++++++++++++ src/layouts/Layout.astro | 10 ++++++++++ src/pages/[lang]/index.astro | 9 +++++++-- 6 files changed, 42 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 30a68c3..d207e07 100644 --- a/index.js +++ b/index.js @@ -54,6 +54,9 @@ app.use(function (req, res, next) { next(); }); app.use("/", express.static("dist/client/")); +app.get("/favicon.ico", (req, res) => { + res.sendFile(path.join(process.cwd(), "dist/client/favicon.svg")); +}) app.get("/search", async (req, res) => { try { const { query } = req.query; diff --git a/public/favicon.svg b/public/favicon.svg index 48ebf60..ad315db 100644 --- a/public/favicon.svg +++ b/public/favicon.svg @@ -1,5 +1,4 @@ - { iframe.style.opacity = 0; topbar.style.opacity = 0; @@ -191,6 +192,24 @@ } } + function updateProxiedFavicon(iframe) { + let proxiedFavicon = document.getElementById("proxied-favicon"); + if (iframe) { + if (iframe.contentDocument) { + let favicon = iframe.contentDocument.querySelector("link[rel='icon']") || iframe.contentDocument.querySelector("link[rel*='icon']"); + if (favicon) { + proxiedFavicon.src = favicon.href; + } else { + proxiedFavicon.src = "/favicon.ico"; + } + return; + } + } + setTimeout(() => updateProxiedFavicon(iframe), 400); + + } + + function iframeURLChange(iframe, callback) { var lastDispatched = null; @@ -199,6 +218,7 @@ if (newHref !== lastDispatched) { callback(newHref); + lastDispatched = newHref; } }; @@ -218,6 +238,7 @@ iframe.addEventListener("load", function () { attachUnload(); + updateProxiedFavicon(iframe); // Just in case the change wasn't dispatched during the unload event... dispatchChange(); diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 51581aa..2f77df9 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -193,6 +193,16 @@ const { title, optionalPreloads } = Astro.props; opacity: 0; gap: 10px; } + .top-bar-right, .top-bar-left { + display: flex; + justify-content: center; + align-items: center; + gap: 10px; + height: 100%; + } + #proxied-favicon { + height: 80%; + } #close-button { padding: 5px; padding-inline: 40px; diff --git a/src/pages/[lang]/index.astro b/src/pages/[lang]/index.astro index 867acc7..f3c7ce5 100644 --- a/src/pages/[lang]/index.astro +++ b/src/pages/[lang]/index.astro @@ -27,8 +27,13 @@ export function getStaticPaths() {
Loading...
- - +
+ +
+
+ + +