From 2703cac433f572d00ae8c0bac7d05b2c87664844 Mon Sep 17 00:00:00 2001 From: MiTHRAL Date: Tue, 21 Apr 2026 21:03:24 -0400 Subject: [PATCH] fix: broaden logo detection to catch login/logout screen Revolt logo Co-Authored-By: Claude Sonnet 4.6 --- src/native/window.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/native/window.ts b/src/native/window.ts index 3c44bb6..d3975c4 100644 --- a/src/native/window.ts +++ b/src/native/window.ts @@ -214,18 +214,29 @@ function injectBranding(wc: Electron.WebContents) { const BRAND_RE = /\\b(Revolt|Stoat)\\b/g; const SKIP_TAGS = new Set(['SCRIPT','STYLE','TEXTAREA','INPUT','CODE','PRE']); + function isLogoImg(img) { + var src = img.getAttribute('src') || ''; + var alt = (img.getAttribute('alt') || '').toLowerCase(); + // explicit brand name in src or alt + if (src.includes('revolt') || src.includes('stoat')) return true; + if (alt === 'revolt' || alt === 'stoat') return true; + // any asset image whose alt contains logo/brand keywords + if (/revolt|stoat|logo/i.test(alt)) return true; + // hashed asset paths with no alt — likely a logo if it's an svg or small png + // and sits inside a known logo/brand container + var parent = img.closest('[class*="logo"],[class*="Logo"],[class*="brand"],[class*="Brand"],[class*="wordmark"],[class*="Wordmark"],[class*="header"],[class*="auth"],[class*="login"],[class*="splash"]'); + if (parent && /\\.(svg|png|webp)/.test(src)) return true; + return false; + } + function patchImages() { document.querySelectorAll('img').forEach(function(img) { - var src = img.getAttribute('src') || ''; - var alt = (img.getAttribute('alt') || '').toLowerCase(); - if ( - src.includes('revolt') || src.includes('stoat') || - alt === 'revolt' || alt === 'stoat' || - (src.startsWith('/') && /\\.(svg|png|webp)/.test(src) && /revolt|stoat|logo/i.test(alt)) - ) { + if (img.dataset.sanctumPatched) return; + if (isLogoImg(img)) { img.src = LOGO; img.removeAttribute('srcset'); img.alt = 'Sanctum'; + img.dataset.sanctumPatched = '1'; } }); }