From 311277abaa0a4f3e80a37b13f2ab5cabb06924a8 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Thu, 23 Dec 2021 23:36:32 +0100 Subject: feat: Set some options in main process * Remove sophie and electron from the user-agent sting whenever possible * Disable MPRIS integration --- packages/main/src/index.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'packages/main') diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts index 59b9ecb..0530e32 100644 --- a/packages/main/src/index.ts +++ b/packages/main/src/index.ts @@ -44,8 +44,24 @@ if (!isSingleInstance) { process.exit(0); } +// Alwayse enable sandboxing. app.enableSandbox(); +// Remove sophie and electron from the user-agent string to avoid detection. +const originalUserAgent = app.userAgentFallback; +// Removing the electron version breaks redux devtools, so we only do this in production. +if (!isDevelopment) { + const userAgent = originalUserAgent.replaceAll(/ ([Ss]ophie|Electron)\/[0-9.]+/g, ''); + app.userAgentFallback = userAgent; +} + +// Disable chromium's MPRIS integration, which is usually more annoying +// (triggered by random sounds played by websites) than useful. +app.commandLine.appendSwitch( + 'disable-features', + 'HardwareMediaKeyHandling,MediaSessionService', +); + if (isDevelopment) { installDevToolsExtensions(app); } @@ -74,6 +90,8 @@ async function createWindow(): Promise { const { webContents } = mainWindow; + webContents.userAgent = originalUserAgent; + webContents.on('ipc-message', (_event, channel, ...args) => { try { switch (channel) { -- cgit v1.2.3-54-g00ecf