From 9385499c4b951df8b9d41ae0ae5118a65445eacd Mon Sep 17 00:00:00 2001 From: MiTHRAL Date: Tue, 21 Apr 2026 20:13:19 -0400 Subject: [PATCH] feat: replace all Revolt/Stoat branding text and images with Sanctum Co-Authored-By: Claude Sonnet 4.6 --- src/native/window.ts | 55 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/src/native/window.ts b/src/native/window.ts index 47341e2..3c44bb6 100644 --- a/src/native/window.ts +++ b/src/native/window.ts @@ -206,21 +206,22 @@ export function createMainWindow() { function injectBranding(wc: Electron.WebContents) { const logoUrl = windowIconAsset; wc.insertCSS(` - /* Hide Revolt text/wordmark labels */ [class*="wordmark"], [class*="Wordmark"], [data-app-name] { display: none !important; } `); wc.executeJavaScript(` (function() { 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) { var src = img.getAttribute('src') || ''; var alt = (img.getAttribute('alt') || '').toLowerCase(); if ( - src.includes('revolt') || - alt === 'revolt' || - alt === 'stoat' || - (src.startsWith('/') && src.match(/\\.(svg|png|webp)/) && alt.match(/revolt|logo/i)) + 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.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() {}); }