feat: replace all Revolt/Stoat branding text and images with Sanctum
All checks were successful
Build & Release / build (push) Successful in 2m57s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MiTHRAL 2026-04-21 20:13:19 -04:00
parent 7e90058e7a
commit 9385499c4b

View file

@ -206,21 +206,22 @@ export function createMainWindow() {
function injectBranding(wc: Electron.WebContents) { function injectBranding(wc: Electron.WebContents) {
const logoUrl = windowIconAsset; const logoUrl = windowIconAsset;
wc.insertCSS(` wc.insertCSS(`
/* Hide Revolt text/wordmark labels */
[class*="wordmark"], [class*="Wordmark"], [data-app-name] { display: none !important; } [class*="wordmark"], [class*="Wordmark"], [data-app-name] { display: none !important; }
`); `);
wc.executeJavaScript(` wc.executeJavaScript(`
(function() { (function() {
const LOGO = ${JSON.stringify(logoUrl)}; const LOGO = ${JSON.stringify(logoUrl)};
function patch() { 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) { 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 ( if (
src.includes('revolt') || src.includes('revolt') || src.includes('stoat') ||
alt === 'revolt' || alt === 'revolt' || alt === 'stoat' ||
alt === 'stoat' || (src.startsWith('/') && /\\.(svg|png|webp)/.test(src) && /revolt|stoat|logo/i.test(alt))
(src.startsWith('/') && src.match(/\\.(svg|png|webp)/) && alt.match(/revolt|logo/i))
) { ) {
img.src = LOGO; img.src = LOGO;
img.removeAttribute('srcset'); img.removeAttribute('srcset');
@ -228,8 +229,46 @@ function injectBranding(wc: Electron.WebContents) {
} }
}); });
} }
patch();
new MutationObserver(patch).observe(document.documentElement, { childList: true, subtree: true }); function patchText(root) {
var walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
var node;
while ((node = walker.nextNode())) {
if (SKIP_TAGS.has(node.parentElement && node.parentElement.tagName)) continue;
if (BRAND_RE.test(node.nodeValue)) {
node.nodeValue = node.nodeValue.replace(BRAND_RE, 'Sanctum');
}
BRAND_RE.lastIndex = 0;
}
}
function patchTitle() {
if (document.title && BRAND_RE.test(document.title)) {
document.title = document.title.replace(BRAND_RE, 'Sanctum');
}
BRAND_RE.lastIndex = 0;
}
function patch(root) {
patchImages();
patchText(root || document.body);
patchTitle();
}
patch(document.documentElement);
new MutationObserver(function(mutations) {
mutations.forEach(function(m) {
m.addedNodes.forEach(function(n) {
if (n.nodeType === 1) patch(n);
else if (n.nodeType === 3 && !SKIP_TAGS.has(n.parentElement && n.parentElement.tagName)) {
if (BRAND_RE.test(n.nodeValue)) n.nodeValue = n.nodeValue.replace(BRAND_RE, 'Sanctum');
BRAND_RE.lastIndex = 0;
}
});
});
patchTitle();
}).observe(document.documentElement, { childList: true, subtree: true });
})(); })();
`, true).catch(function() {}); `, true).catch(function() {});
} }