From 043efa332718b46f9707e9abcccea249f77e17bb Mon Sep 17 00:00:00 2001 From: Penny Date: Fri, 17 May 2024 20:31:54 -0400 Subject: [PATCH 1/4] Fix google login windows --- src/utils/Window.ts | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/src/utils/Window.ts b/src/utils/Window.ts index 6188e5a..2e0ee96 100644 --- a/src/utils/Window.ts +++ b/src/utils/Window.ts @@ -59,33 +59,21 @@ export async function load(app: Electron.App) { Config.set(app, 'window_height', h); }); - win.webContents.setWindowOpenHandler((details) => { - if (details.url.includes('accounts.google.com')) { - dialog.showMessageBox({ - type: 'warning', - title: 'Google login', - message: 'Google login is broken, if someone knows how to fix it, please open an issue/PR on GitHub. Thanks!' - }); - return { action: 'deny' }; - } else if (details.url.includes('facebook.com') || details.url.includes('apple.com')) { - return { - action: 'allow', - overrideBrowserWindowOptions: { - center: true, - maximizable: true, - minimizable: true, - closable: true, - autoHideMenuBar: true, - fullscreenable: false, - resizable: true, - title: 'Deezer Discord RPC', - icon: join(__dirname, '..', 'img', 'app.ico'), - } - }; - } else { - shell.openExternal(details.url); - return { action: 'deny' }; - } + win.webContents.setWindowOpenHandler(() => { + return { + action: 'allow', + overrideBrowserWindowOptions: { + center: true, + maximizable: true, + minimizable: true, + closable: true, + autoHideMenuBar: true, + fullscreenable: false, + resizable: true, + title: 'Deezer Discord RPC', + icon: join(__dirname, '..', 'img', 'app.ico'), + } + }; }); win.on('close', (e) => { From 87e43e0b707f966626ae136c70cbdc62a6c9fe33 Mon Sep 17 00:00:00 2001 From: Penny Date: Fri, 17 May 2024 20:36:35 -0400 Subject: [PATCH 2/4] Readd shell.openExternal for non login window open events --- src/utils/Window.ts | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/utils/Window.ts b/src/utils/Window.ts index 2e0ee96..560bdeb 100644 --- a/src/utils/Window.ts +++ b/src/utils/Window.ts @@ -59,21 +59,26 @@ export async function load(app: Electron.App) { Config.set(app, 'window_height', h); }); - win.webContents.setWindowOpenHandler(() => { - return { - action: 'allow', - overrideBrowserWindowOptions: { - center: true, - maximizable: true, - minimizable: true, - closable: true, - autoHideMenuBar: true, - fullscreenable: false, - resizable: true, - title: 'Deezer Discord RPC', - icon: join(__dirname, '..', 'img', 'app.ico'), - } - }; + win.webContents.setWindowOpenHandler((details) => { + if (details.url.includes('facebook.com') || details.url.includes('apple.com') || details.url.includes('accounts.google.com')) { + return { + action: 'allow', + overrideBrowserWindowOptions: { + center: true, + maximizable: true, + minimizable: true, + closable: true, + autoHideMenuBar: true, + fullscreenable: false, + resizable: true, + title: 'Deezer Discord RPC', + icon: join(__dirname, '..', 'img', 'app.ico'), + } + }; + } else { + shell.openExternal(details.url); + return { action: 'deny' }; + } }); win.on('close', (e) => { From 1e523e48d231c5eddc127fea9d2b2a13b4427ce6 Mon Sep 17 00:00:00 2001 From: Penny Date: Fri, 17 May 2024 20:45:12 -0400 Subject: [PATCH 3/4] Remove dialog import --- src/utils/Window.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/Window.ts b/src/utils/Window.ts index 560bdeb..e02392b 100644 --- a/src/utils/Window.ts +++ b/src/utils/Window.ts @@ -6,7 +6,7 @@ import * as DiscordWebSocket from './DiscordWebSocket'; import * as RPC from './RPC'; import { log } from './Log'; import { runJs, wait } from '../functions'; -import { BrowserWindow, ipcMain, shell, nativeImage, session, dialog } from 'electron'; +import { BrowserWindow, ipcMain, shell, nativeImage, session } from 'electron'; import { setActivity } from './Activity'; export let win: BrowserWindow; From 0e2c686e0a64d2b771b97ecc700d4e5a42d3561f Mon Sep 17 00:00:00 2001 From: Penny Date: Sat, 18 May 2024 15:05:07 -0400 Subject: [PATCH 4/4] Make BeforeSendHeaders only change them if going to deezer --- src/utils/Window.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/Window.ts b/src/utils/Window.ts index e02392b..38f185c 100644 --- a/src/utils/Window.ts +++ b/src/utils/Window.ts @@ -43,7 +43,9 @@ export async function load(app: Electron.App) { await setThumbarButtons(); session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => { - details.requestHeaders['User-Agent'] = userAgent; + if (details.url.includes('deezer.com')) { + details.requestHeaders['User-Agent'] = userAgent; + } callback({ cancel: false, requestHeaders: details.requestHeaders }); });