Compare commits
2 commits
f0c4ffbc00
...
a308aa1987
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a308aa1987 | ||
|
|
2703cac433 |
2 changed files with 59 additions and 7 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 47 KiB |
|
|
@ -138,6 +138,8 @@ export function createMainWindow() {
|
|||
) {
|
||||
event.preventDefault();
|
||||
mainWindow.webContents.reload();
|
||||
} else if (input.key === "F12") {
|
||||
mainWindow.webContents.toggleDevTools();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -214,18 +216,67 @@ 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';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function replaceSvgWithLogo(svg) {
|
||||
var box = svg.getBoundingClientRect();
|
||||
if (box.height > 0 && box.height < 48) { svg.parentNode.removeChild(svg); return; }
|
||||
var size = '96px';
|
||||
var wrap = document.createElement('div');
|
||||
wrap.style.cssText = 'display:flex;align-items:center;justify-content:center;width:100%;';
|
||||
var img = document.createElement('img');
|
||||
img.src = LOGO;
|
||||
img.alt = 'Sanctum';
|
||||
img.style.cssText = 'width:' + size + ';height:' + size + ';object-fit:contain;flex-shrink:0;';
|
||||
img.dataset.sanctumPatched = '1';
|
||||
wrap.appendChild(img);
|
||||
svg.parentNode.replaceChild(wrap, svg);
|
||||
}
|
||||
|
||||
function patchSVGs() {
|
||||
document.querySelectorAll('svg').forEach(function(svg) {
|
||||
if (svg.dataset.sanctumPatched) return;
|
||||
// Match the Revolt wordmark SVG by its unique path data fingerprint
|
||||
var paths = svg.querySelectorAll('path');
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
var d = paths[i].getAttribute('d') || '';
|
||||
if (d.includes('M478.909') || d.includes('M5.063') || d.includes('Revolt')) {
|
||||
replaceSvgWithLogo(svg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Also catch any wide wordmark-style SVG in an auth/login container
|
||||
var parent = svg.closest('[class*="logo"],[class*="Logo"],[class*="brand"],[class*="Brand"],[class*="wordmark"],[class*="Wordmark"],[class*="auth"],[class*="login"],[class*="splash"],[class*="Landing"]');
|
||||
if (parent) {
|
||||
var box = svg.getBoundingClientRect();
|
||||
if (box.width > 80 && box.width / (box.height || 1) > 2) {
|
||||
replaceSvgWithLogo(svg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -251,6 +302,7 @@ function injectBranding(wc: Electron.WebContents) {
|
|||
|
||||
function patch(root) {
|
||||
patchImages();
|
||||
patchSVGs();
|
||||
patchText(root || document.body);
|
||||
patchTitle();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue