Shows favicon when page is loaded in embed mode now.

This commit is contained in:
wearrrrr 2024-03-01 22:48:04 -06:00
parent 815f4d5999
commit f8b92dc0b9
6 changed files with 42 additions and 4 deletions

View file

@ -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;

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 512 512" xml:space="preserve">
<path style="fill:#1E0478;" d="M494.176,64.787c15.4,22.42,20.974,52.758,16.123,88.421c-4.751,34.914-19.365,74.181-42.346,113.946

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

@ -1 +1 @@
Subproject commit 8793db1e2fe64cae8936c00bcd4f333f158f6ebd
Subproject commit 11287d0a834c672a55d10164dbfefe9ee1922d3d

View file

@ -110,6 +110,7 @@
topbar.style.opacity = 1;
topbar.style.pointerEvents = "auto";
updateProxiedFavicon();
closeButton.onclick = () => {
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();

View file

@ -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;

View file

@ -27,8 +27,13 @@ export function getStaticPaths() {
<div id="loading-content">Loading...</div>
</form>
<div id="top-bar">
<button id="close-button">Close</button>
<span id="url-text"></span>
<div class="top-bar-left">
<button id="close-button">Close</button>
</div>
<div class="top-bar-right">
<img id="proxied-favicon" />
<span id="url-text"></span>
</div>
</div>
<iframe title="proxy-iframe" id="proxy-frame"></iframe>
</div>