Compare commits

..
2 Commits
Author SHA1 Message Date
kdee 8da0d884ed console fix 1 2026-09-23 12:51:21 -07:00
kdee 69f113891f logo fix 2 2026-09-23 12:49:32 -07:00
+16 -2
View File
@@ -4,6 +4,7 @@
// incrementversion DISMISSED_KEY // incrementversion DISMISSED_KEY
const DISMISSED_KEY = 'jf-banner-dismissed-v1'; const DISMISSED_KEY = 'jf-banner-dismissed-v1';
const BANNER_ID = 'custom-announcement-banner'; const BANNER_ID = 'custom-announcement-banner';
const SCRIPT_START = Date.now();
// Edit these to change banner content: // Edit these to change banner content:
const BANNER_HTML = ` const BANNER_HTML = `
@@ -100,7 +101,10 @@
offsetElements.add(el); offsetElements.add(el);
}); });
if (offsetPx > 0 && candidates.size === 0) { // Jellyfin's SPA mounts its header asynchronously after DOMContentLoaded,
// so an empty result in the first few seconds is expected, not a bug.
// Only warn once things have had time to settle.
if (offsetPx > 0 && candidates.size === 0 && Date.now() - SCRIPT_START > 4000) {
console.warn('[custom-banner] No fixed top navigation elements detected to push down; banner may overlap the menu.'); console.warn('[custom-banner] No fixed top navigation elements detected to push down; banner may overlap the menu.');
} }
} }
@@ -116,14 +120,24 @@
// filename inject-banner.sh replaces for the top-bar logo; keep these two // filename inject-banner.sh replaces for the top-bar logo; keep these two
// in sync if that ever changes again. // in sync if that ever changes again.
const LOGO_IMG_MATCH = 'icon-transparent'; const LOGO_IMG_MATCH = 'icon-transparent';
const LOGO_MAX_SIZE = '2em'; // grow the icon now that the text next to it is gone
function hideLogoText() { function hideLogoText() {
const logoImg = document.querySelector('img[src*="' + LOGO_IMG_MATCH + '"]'); const logoImg = document.querySelector('img[src*="' + LOGO_IMG_MATCH + '"]');
if (!logoImg) return; if (!logoImg) return;
const container = logoImg.parentElement;
logoImg.style.setProperty('max-height', LOGO_MAX_SIZE, 'important');
logoImg.style.setProperty('max-width', LOGO_MAX_SIZE, 'important');
// The image is usually wrapped in its own icon span, so the text label
// is a sibling of that wrapper, not of the <img> itself. Walk up to the
// whole clickable logo button/link and hide every child that isn't part
// of the branch containing the image.
const container = logoImg.closest('button, a, [role="button"]') || logoImg.parentElement;
if (!container) return; if (!container) return;
Array.prototype.forEach.call(container.childNodes, function (node) { Array.prototype.forEach.call(container.childNodes, function (node) {
if (node === logoImg) return; if (node === logoImg) return;
if (node.nodeType === Node.ELEMENT_NODE && node.contains(logoImg)) return;
if (node.nodeType === Node.TEXT_NODE) { if (node.nodeType === Node.TEXT_NODE) {
if (node.textContent.trim()) node.textContent = ''; if (node.textContent.trim()) node.textContent = '';
} else if (node.nodeType === Node.ELEMENT_NODE && node.style.display !== 'none') { } else if (node.nodeType === Node.ELEMENT_NODE && node.style.display !== 'none') {