logo fix 2
This commit is contained in:
1 parent
3674f07716
commit
69f113891f
1 file changed
+11
-1
@@ -116,14 +116,24 @@
|
||||
// filename inject-banner.sh replaces for the top-bar logo; keep these two
|
||||
// in sync if that ever changes again.
|
||||
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() {
|
||||
const logoImg = document.querySelector('img[src*="' + LOGO_IMG_MATCH + '"]');
|
||||
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;
|
||||
Array.prototype.forEach.call(container.childNodes, function (node) {
|
||||
if (node === logoImg) return;
|
||||
if (node.nodeType === Node.ELEMENT_NODE && node.contains(logoImg)) return;
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
if (node.textContent.trim()) node.textContent = '';
|
||||
} else if (node.nodeType === Node.ELEMENT_NODE && node.style.display !== 'none') {
|
||||
|
||||
Reference in new issue
Block a user