feat: inject Sanctum branding to replace Revolt logo in webview
All checks were successful
Build & Release / build (push) Successful in 2m29s
All checks were successful
Build & Release / build (push) Successful in 2m29s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f9b7a9739f
commit
581a853b6f
1 changed files with 35 additions and 1 deletions
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue