From 581a853b6ff1e84fa8fc0bcae7f510cc02fe7a0e Mon Sep 17 00:00:00 2001 From: MiTHRAL Date: Tue, 21 Apr 2026 15:44:48 -0400 Subject: [PATCH] feat: inject Sanctum branding to replace Revolt logo in webview Co-Authored-By: Claude Sonnet 4.6 --- src/native/window.ts | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/native/window.ts b/src/native/window.ts index 5164de6..47341e2 100644 --- a/src/native/window.ts +++ b/src/native/window.ts @@ -142,7 +142,10 @@ export function createMainWindow() { }); // send the config - mainWindow.webContents.on("did-finish-load", () => config.sync()); + mainWindow.webContents.on("did-finish-load", () => { + config.sync(); + injectBranding(mainWindow.webContents); + }); // configure spellchecker context menu mainWindow.webContents.on("context-menu", (_, params) => { @@ -200,6 +203,37 @@ export function createMainWindow() { // setInterval(() => setBadgeCount((++i % 30) + 1), 1000); } +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() { + 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)) + ) { + img.src = LOGO; + img.removeAttribute('srcset'); + img.alt = 'Sanctum'; + } + }); + } + patch(); + new MutationObserver(patch).observe(document.documentElement, { childList: true, subtree: true }); + })(); + `, true).catch(function() {}); +} + /** * Quit the entire app */