From 2fb47933acc7a616141dc057ecf955f3d348e25c Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Mon, 13 Dec 2021 21:06:52 +0200 Subject: [PATCH] fix useragents --- index.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 624fa1ec..b14d3f84 100644 --- a/index.js +++ b/index.js @@ -165,6 +165,22 @@ function createMainWindow() { } app.once("browser-window-created", (event, win) => { + // Force user-agent "Firefox Windows" for Google OAuth to work + // From https://github.com/firebase/firebase-js-sdk/issues/2478#issuecomment-571356751 + // Uses custom user agent to Google alert with a correct device type (https://github.com/th-ch/youtube-music/issues/327) + // User agents are from https://developers.whatismybrowser.com/useragents/explore/ + + const userAgents = { + mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36", + windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36", + linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36", + } + + app.userAgentFallback = + is.macOS() ? userAgents.mac : + is.windows() ? userAgents.windows : + userAgents.linux; + setupSongInfo(win); loadPlugins(win); @@ -199,22 +215,6 @@ app.once("browser-window-created", (event, win) => { event.preventDefault(); }); - // Force user-agent "Firefox Windows" for Google OAuth to work - // From https://github.com/firebase/firebase-js-sdk/issues/2478#issuecomment-571356751 - // Uses custom user agent to Google alert with a correct device type (https://github.com/th-ch/youtube-music/issues/327) - // User agents are from https://developers.whatismybrowser.com/useragents/explore/ - - const userAgents = { - mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 12.0; rv:95.0) Gecko/20100101 Firefox/95.0", - windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0", - linux: "Mozilla/5.0 (Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0", - } - - win.webContents.userAgent = - is.macOS() ? userAgents.mac : - is.windows() ? userAgents.windows : - userAgents.linux; - win.webContents.on( "new-window", (e, url, frameName, disposition, options) => {