diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-12-23 23:36:32 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2021-12-23 23:37:55 +0100 |
commit | 311277abaa0a4f3e80a37b13f2ab5cabb06924a8 (patch) | |
tree | 65a7a1f77022c993a6ce333c63fb25fc72e92e56 /packages/main/src | |
parent | feat: Add BrowserView and synchronize its position (diff) | |
download | sophie-311277abaa0a4f3e80a37b13f2ab5cabb06924a8.tar.gz sophie-311277abaa0a4f3e80a37b13f2ab5cabb06924a8.tar.zst sophie-311277abaa0a4f3e80a37b13f2ab5cabb06924a8.zip |
feat: Set some options in main process
* Remove sophie and electron from the user-agent sting whenever possible
* Disable MPRIS integration
Diffstat (limited to 'packages/main/src')
-rw-r--r-- | packages/main/src/index.ts | 18 |
1 files changed, 18 insertions, 0 deletions
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) { | |||
44 | process.exit(0); | 44 | process.exit(0); |
45 | } | 45 | } |
46 | 46 | ||
47 | // Alwayse enable sandboxing. | ||
47 | app.enableSandbox(); | 48 | app.enableSandbox(); |
48 | 49 | ||
50 | // Remove sophie and electron from the user-agent string to avoid detection. | ||
51 | const originalUserAgent = app.userAgentFallback; | ||
52 | // Removing the electron version breaks redux devtools, so we only do this in production. | ||
53 | if (!isDevelopment) { | ||
54 | const userAgent = originalUserAgent.replaceAll(/ ([Ss]ophie|Electron)\/[0-9.]+/g, ''); | ||
55 | app.userAgentFallback = userAgent; | ||
56 | } | ||
57 | |||
58 | // Disable chromium's MPRIS integration, which is usually more annoying | ||
59 | // (triggered by random sounds played by websites) than useful. | ||
60 | app.commandLine.appendSwitch( | ||
61 | 'disable-features', | ||
62 | 'HardwareMediaKeyHandling,MediaSessionService', | ||
63 | ); | ||
64 | |||
49 | if (isDevelopment) { | 65 | if (isDevelopment) { |
50 | installDevToolsExtensions(app); | 66 | installDevToolsExtensions(app); |
51 | } | 67 | } |
@@ -74,6 +90,8 @@ async function createWindow(): Promise<void> { | |||
74 | 90 | ||
75 | const { webContents } = mainWindow; | 91 | const { webContents } = mainWindow; |
76 | 92 | ||
93 | webContents.userAgent = originalUserAgent; | ||
94 | |||
77 | webContents.on('ipc-message', (_event, channel, ...args) => { | 95 | webContents.on('ipc-message', (_event, channel, ...args) => { |
78 | try { | 96 | try { |
79 | switch (channel) { | 97 | switch (channel) { |