fix: broaden logo detection to catch login/logout screen Revolt logo
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f0c4ffbc00
commit
2703cac433
1 changed files with 18 additions and 7 deletions
|
|
@ -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 patchImages() {
|
||||
document.querySelectorAll('img').forEach(function(img) {
|
||||
function isLogoImg(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))
|
||||
) {
|
||||
// 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) {
|
||||
if (img.dataset.sanctumPatched) return;
|
||||
if (isLogoImg(img)) {
|
||||
img.src = LOGO;
|
||||
img.removeAttribute('srcset');
|
||||
img.alt = 'Sanctum';
|
||||
img.dataset.sanctumPatched = '1';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue