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 BRAND_RE = /\\b(Revolt|Stoat)\\b/g;
|
||||||
const SKIP_TAGS = new Set(['SCRIPT','STYLE','TEXTAREA','INPUT','CODE','PRE']);
|
const SKIP_TAGS = new Set(['SCRIPT','STYLE','TEXTAREA','INPUT','CODE','PRE']);
|
||||||
|
|
||||||
function patchImages() {
|
function isLogoImg(img) {
|
||||||
document.querySelectorAll('img').forEach(function(img) {
|
|
||||||
var src = img.getAttribute('src') || '';
|
var src = img.getAttribute('src') || '';
|
||||||
var alt = (img.getAttribute('alt') || '').toLowerCase();
|
var alt = (img.getAttribute('alt') || '').toLowerCase();
|
||||||
if (
|
// explicit brand name in src or alt
|
||||||
src.includes('revolt') || src.includes('stoat') ||
|
if (src.includes('revolt') || src.includes('stoat')) return true;
|
||||||
alt === 'revolt' || alt === 'stoat' ||
|
if (alt === 'revolt' || alt === 'stoat') return true;
|
||||||
(src.startsWith('/') && /\\.(svg|png|webp)/.test(src) && /revolt|stoat|logo/i.test(alt))
|
// 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.src = LOGO;
|
||||||
img.removeAttribute('srcset');
|
img.removeAttribute('srcset');
|
||||||
img.alt = 'Sanctum';
|
img.alt = 'Sanctum';
|
||||||
|
img.dataset.sanctumPatched = '1';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue