Compare commits
No commits in common. "a308aa19872f5f04df450848a394caf019ed31e8" and "f0c4ffbc006bcf5c2418d8aa495e40f93719a407" have entirely different histories.
a308aa1987
...
f0c4ffbc00
2 changed files with 7 additions and 59 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 43 KiB |
|
|
@ -138,8 +138,6 @@ export function createMainWindow() {
|
||||||
) {
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
mainWindow.webContents.reload();
|
mainWindow.webContents.reload();
|
||||||
} else if (input.key === "F12") {
|
|
||||||
mainWindow.webContents.toggleDevTools();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -216,67 +214,18 @@ 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 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() {
|
function patchImages() {
|
||||||
document.querySelectorAll('img').forEach(function(img) {
|
document.querySelectorAll('img').forEach(function(img) {
|
||||||
if (img.dataset.sanctumPatched) return;
|
var src = img.getAttribute('src') || '';
|
||||||
if (isLogoImg(img)) {
|
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))
|
||||||
|
) {
|
||||||
img.src = LOGO;
|
img.src = LOGO;
|
||||||
img.removeAttribute('srcset');
|
img.removeAttribute('srcset');
|
||||||
img.alt = 'Sanctum';
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -302,7 +251,6 @@ function injectBranding(wc: Electron.WebContents) {
|
||||||
|
|
||||||
function patch(root) {
|
function patch(root) {
|
||||||
patchImages();
|
patchImages();
|
||||||
patchSVGs();
|
|
||||||
patchText(root || document.body);
|
patchText(root || document.body);
|
||||||
patchTitle();
|
patchTitle();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue