From dd122666c5e3c238ead3498329e0a6b2e4470439 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Mon, 13 Dec 2021 00:12:01 +0200 Subject: [PATCH 01/18] update useragents --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 50e31d10..4f8a35b1 100644 --- a/index.js +++ b/index.js @@ -205,9 +205,9 @@ app.once("browser-window-created", (event, win) => { // 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 10.14; rv:70.0) Gecko/20100101 Firefox/70.0", - windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0", - linux: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0", + 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", } const userAgent = From e1e974800240e0129ab69710f055fe7cd2c128ef Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Mon, 13 Dec 2021 01:11:13 +0200 Subject: [PATCH 02/18] always on useragent --- index.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 4f8a35b1..83e85814 100644 --- a/index.js +++ b/index.js @@ -197,6 +197,19 @@ app.once("browser-window-created", (event, win) => { event.preventDefault(); }); + 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", + } + + const userAgent = + is.macOS() ? userAgents.mac : + is.windows() ? userAgents.windows : + userAgents.linux; + + win.webContents.userAgent = userAgent; + win.webContents.on("will-navigate", (_, url) => { if (url.startsWith("https://accounts.google.com")) { // Force user-agent "Firefox Windows" for Google OAuth to work @@ -204,16 +217,6 @@ app.once("browser-window-created", (event, win) => { // Only set on accounts.google.com, otherwise querySelectors in preload scripts fail (?) // 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", - } - - const userAgent = - is.macOS() ? userAgents.mac : - is.windows() ? userAgents.windows : - userAgents.linux; win.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => { details.requestHeaders["User-Agent"] = userAgent; From 4fd683ed232c6ed530a1ad5d9412f8ee90d39ab3 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Mon, 13 Dec 2021 20:10:36 +0200 Subject: [PATCH 03/18] update electron & remote module --- index.js | 30 +++++++-------------- package.json | 5 ++-- plugins/downloader/utils.js | 3 ++- plugins/in-app-menu/front.js | 6 +++-- plugins/precise-volume/front.js | 7 ++--- plugins/quality-changer/front.js | 2 +- preload.js | 2 +- yarn.lock | 45 +++++++++++++++++++++++++++----- 8 files changed, 64 insertions(+), 36 deletions(-) diff --git a/index.js b/index.js index 83e85814..624fa1ec 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,8 @@ const path = require("path"); const electron = require("electron"); +const remote = require('@electron/remote/main'); +remote.initialize(); const enhanceWebRequest = require("electron-better-web-request").default; const is = require("electron-is"); const unhandled = require("electron-unhandled"); @@ -98,7 +100,6 @@ function createMainWindow() { preload: path.join(__dirname, "preload.js"), nodeIntegrationInSubFrames: true, nativeWindowOpen: true, // window.open return Window object(like in regular browsers), not BrowserWindowProxy - enableRemoteModule: true, affinity: "main-window", // main window, and addition windows should work in one process ...(isTesting() ? { @@ -116,6 +117,7 @@ function createMainWindow() { : "default", autoHideMenuBar: config.get("options.hideMenu"), }); + remote.enable(win.webContents); if (windowPosition) { const { x, y } = windowPosition; win.setPosition(x, y); @@ -197,34 +199,22 @@ 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", } - - const userAgent = + + win.webContents.userAgent = is.macOS() ? userAgents.mac : is.windows() ? userAgents.windows : userAgents.linux; - win.webContents.userAgent = userAgent; - - win.webContents.on("will-navigate", (_, url) => { - if (url.startsWith("https://accounts.google.com")) { - // Force user-agent "Firefox Windows" for Google OAuth to work - // From https://github.com/firebase/firebase-js-sdk/issues/2478#issuecomment-571356751 - // Only set on accounts.google.com, otherwise querySelectors in preload scripts fail (?) - // 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/ - - win.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => { - details.requestHeaders["User-Agent"] = userAgent; - cb({ requestHeaders: details.requestHeaders }); - }); - } - }); - win.webContents.on( "new-window", (e, url, frameName, disposition, options) => { diff --git a/package.json b/package.json index 7d21523a..456b6277 100644 --- a/package.json +++ b/package.json @@ -64,12 +64,13 @@ }, "dependencies": { "@cliqz/adblocker-electron": "^1.23.0", + "@electron/remote": "^2.0.1", "@ffmpeg/core": "^0.10.0", "@ffmpeg/ffmpeg": "^0.10.0", "async-mutex": "^0.3.2", "browser-id3-writer": "^4.4.0", - "custom-electron-prompt": "^1.3.1", "chokidar": "^3.5.2", + "custom-electron-prompt": "^1.3.1", "custom-electron-titlebar": "^3.2.7", "discord-rpc": "^3.2.0", "electron-better-web-request": "^1.0.1", @@ -88,7 +89,7 @@ "ytpl": "^2.2.3" }, "devDependencies": { - "electron": "^12.2.2", + "electron": "^16.0.2", "electron-builder": "^22.10.5", "electron-devtools-installer": "^3.1.1", "electron-icon-maker": "0.0.5", diff --git a/plugins/downloader/utils.js b/plugins/downloader/utils.js index 07bca3a5..88eeba01 100644 --- a/plugins/downloader/utils.js +++ b/plugins/downloader/utils.js @@ -1,7 +1,8 @@ const electron = require("electron"); +//const remote = require('@electron/remote'); module.exports.getFolder = (customFolder) => - customFolder || (electron.app || electron.remote.app).getPath("downloads"); + customFolder || electron.app.getPath("downloads"); module.exports.defaultMenuDownloadLabel = "Download playlist"; const orderedQualityList = ["maxresdefault", "hqdefault", "mqdefault", "sdddefault"]; diff --git a/plugins/in-app-menu/front.js b/plugins/in-app-menu/front.js index 0ed91a48..f576f588 100644 --- a/plugins/in-app-menu/front.js +++ b/plugins/in-app-menu/front.js @@ -1,4 +1,6 @@ -const { remote, ipcRenderer } = require("electron"); +const { ipcRenderer } = require("electron"); +const { Menu } = require("@electron/remote"); + const customTitlebar = require("custom-electron-titlebar"); function $(selector) { return document.querySelector(selector); } @@ -12,7 +14,7 @@ module.exports = () => { document.title = "Youtube Music"; ipcRenderer.on("updateMenu", function (_event, showMenu) { - bar.updateMenu(showMenu ? remote.Menu.getApplicationMenu() : null); + bar.updateMenu(showMenu ? Menu.getApplicationMenu() : null); }); // Increases the right margin of Navbar background when the scrollbar is visible to avoid blocking it (z-index doesn't affect it) diff --git a/plugins/precise-volume/front.js b/plugins/precise-volume/front.js index 189a20eb..19f63327 100644 --- a/plugins/precise-volume/front.js +++ b/plugins/precise-volume/front.js @@ -1,4 +1,5 @@ -const { ipcRenderer, remote } = require("electron"); +const { ipcRenderer } = require("electron"); +const { globalShortcut } = require('@electron/remote'); const { setOptions } = require("../../config/plugins"); @@ -202,10 +203,10 @@ function setTooltip(volume) { function setupGlobalShortcuts(options) { if (options.globalShortcuts.volumeUp) { - remote.globalShortcut.register((options.globalShortcuts.volumeUp), () => changeVolume(true, options)); + globalShortcut.register((options.globalShortcuts.volumeUp), () => changeVolume(true, options)); } if (options.globalShortcuts.volumeDown) { - remote.globalShortcut.register((options.globalShortcuts.volumeDown), () => changeVolume(false, options)); + globalShortcut.register((options.globalShortcuts.volumeDown), () => changeVolume(false, options)); } } diff --git a/plugins/quality-changer/front.js b/plugins/quality-changer/front.js index 9972c97f..669d39ba 100644 --- a/plugins/quality-changer/front.js +++ b/plugins/quality-changer/front.js @@ -1,5 +1,5 @@ const { ElementFromFile, templatePath } = require("../utils"); -const dialog = require('electron').remote.dialog +const { dialog } = require('@electron/remote'); function $(selector) { return document.querySelector(selector); } diff --git a/preload.js b/preload.js index daffe887..621f46c0 100644 --- a/preload.js +++ b/preload.js @@ -1,6 +1,6 @@ const path = require("path"); -const { remote } = require("electron"); +const remote = require('@electron/remote'); const config = require("./config"); const { fileExists } = require("./plugins/utils"); diff --git a/yarn.lock b/yarn.lock index 1ca05e7f..ac09b28d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -700,7 +700,7 @@ ajv "^6.12.0" ajv-keywords "^3.4.1" -"@electron/get@^1.0.1", "@electron/get@^1.12.4": +"@electron/get@^1.12.4": version "1.12.4" resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.12.4.tgz#a5971113fc1bf8fa12a8789dc20152a7359f06ab" integrity sha512-6nr9DbJPUR9Xujw6zD3y+rS95TyItEVM0NVjt1EehY2vUWfIgPiIPVHxCvaTS0xr2B+DRxovYVKbuOWqC35kjg== @@ -716,11 +716,32 @@ global-agent "^2.0.2" global-tunnel-ng "^2.7.1" +"@electron/get@^1.13.0": + version "1.13.1" + resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.13.1.tgz#42a0aa62fd1189638bd966e23effaebb16108368" + integrity sha512-U5vkXDZ9DwXtkPqlB45tfYnnYBN8PePp1z/XDCupnSpdrxT8/ThCv9WCwPLf9oqiSGZTkH6dx2jDUPuoXpjkcA== + dependencies: + debug "^4.1.1" + env-paths "^2.2.0" + fs-extra "^8.1.0" + got "^9.6.0" + progress "^2.0.3" + semver "^6.2.0" + sumchecker "^3.0.1" + optionalDependencies: + global-agent "^3.0.0" + global-tunnel-ng "^2.7.1" + "@electron/remote@^1.0.4": version "1.1.0" resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-1.1.0.tgz#167d119c7c03c7778b556fdc4f1f38a44b23f1c2" integrity sha512-yr8gZTkIgJYKbFqExI4QZqMSjn1kL/us9Dl46+TH1EZdhgRtsJ6HDfdsIxu0QEc6Hv+DMAXs69rgquH+8FDk4w== +"@electron/remote@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-2.0.1.tgz#810cbc595a21f0f94641eb2d7e8264063a3f84de" + integrity sha512-bGX4/yB2bPZwXm1DsxgoABgH0Cz7oFtXJgkerB8VrStYdTyvhGAULzNLRn9rVmeAuC3VUDXaXpZIlZAZHpsLIA== + "@electron/universal@1.0.5": version "1.0.5" resolved "https://registry.yarnpkg.com/@electron/universal/-/universal-1.0.5.tgz#b812340e4ef21da2b3ee77b2b4d35c9b86defe37" @@ -3412,12 +3433,12 @@ electron-updater@^4.6.1: lodash.isequal "^4.5.0" semver "^7.3.5" -electron@^12.2.2: - version "12.2.2" - resolved "https://registry.yarnpkg.com/electron/-/electron-12.2.2.tgz#9627594d6b5bb589f00355989d316b6542539e54" - integrity sha512-Oma/nIfvgql9JjAxdB9gQk//qxpJaI6PgMocYMiW4kFyLi+8jS6oGn33QG3FESS//cw09KRnWmA9iutuFAuXtw== +electron@^16.0.2: + version "16.0.4" + resolved "https://registry.yarnpkg.com/electron/-/electron-16.0.4.tgz#87dfe21d17608537fc6df292c437362297566a73" + integrity sha512-IptwmowvMP1SFOmZLh6rrURwfnOxbDBXBRBcaOdfBM5I+B9mgtdNwzNC3ymFFNzEkZUwdOyg9fu3iyjAAQIQgw== dependencies: - "@electron/get" "^1.0.1" + "@electron/get" "^1.13.0" "@types/node" "^14.6.2" extract-zip "^1.0.3" @@ -4395,6 +4416,18 @@ global-agent@^2.0.2: semver "^7.3.2" serialize-error "^7.0.1" +global-agent@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/global-agent/-/global-agent-3.0.0.tgz#ae7cd31bd3583b93c5a16437a1afe27cc33a1ab6" + integrity sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q== + dependencies: + boolean "^3.0.1" + es6-error "^4.1.1" + matcher "^3.0.0" + roarr "^2.15.3" + semver "^7.3.2" + serialize-error "^7.0.1" + global-dirs@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-3.0.0.tgz#70a76fe84ea315ab37b1f5576cbde7d48ef72686" 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 04/18] 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) => { From 66332436284f9ae3266e4cb16bcd7ed7d9ecbf73 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Mon, 13 Dec 2021 21:10:59 +0200 Subject: [PATCH 05/18] use @rozzzly/custom-electron-titlebar --- package.json | 2 +- plugins/in-app-menu/front.js | 2 +- yarn.lock | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 456b6277..eeebd8c7 100644 --- a/package.json +++ b/package.json @@ -67,11 +67,11 @@ "@electron/remote": "^2.0.1", "@ffmpeg/core": "^0.10.0", "@ffmpeg/ffmpeg": "^0.10.0", + "@rozzzly/custom-electron-titlebar": "^3.3.1", "async-mutex": "^0.3.2", "browser-id3-writer": "^4.4.0", "chokidar": "^3.5.2", "custom-electron-prompt": "^1.3.1", - "custom-electron-titlebar": "^3.2.7", "discord-rpc": "^3.2.0", "electron-better-web-request": "^1.0.1", "electron-debug": "^3.2.0", diff --git a/plugins/in-app-menu/front.js b/plugins/in-app-menu/front.js index f576f588..a345f39c 100644 --- a/plugins/in-app-menu/front.js +++ b/plugins/in-app-menu/front.js @@ -2,7 +2,7 @@ const { ipcRenderer } = require("electron"); const { Menu } = require("@electron/remote"); -const customTitlebar = require("custom-electron-titlebar"); +const customTitlebar = require("@rozzzly/custom-electron-titlebar"); function $(selector) { return document.querySelector(selector); } module.exports = () => { diff --git a/yarn.lock b/yarn.lock index ac09b28d..e9e6ca8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -737,6 +737,11 @@ resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-1.1.0.tgz#167d119c7c03c7778b556fdc4f1f38a44b23f1c2" integrity sha512-yr8gZTkIgJYKbFqExI4QZqMSjn1kL/us9Dl46+TH1EZdhgRtsJ6HDfdsIxu0QEc6Hv+DMAXs69rgquH+8FDk4w== +"@electron/remote@^1.1.0": + version "1.2.2" + resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-1.2.2.tgz#4c390a2e669df47af973c09eec106162a296c323" + integrity sha512-PfnXpQGWh4vpX866NNucJRnNOzDRZcsLcLaT32fUth9k0hccsohfxprqEDYLzRg+ZK2xRrtyUN5wYYoHimMCJg== + "@electron/remote@^2.0.1": version "2.0.1" resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-2.0.1.tgz#810cbc595a21f0f94641eb2d7e8264063a3f84de" @@ -1365,6 +1370,13 @@ resolved "https://registry.yarnpkg.com/@remusao/trie/-/trie-1.4.1.tgz#755d09f8a007476334e611f42719b2d581f00720" integrity sha512-yvwa+aCyYI/UjeD39BnpMypG8N06l86wIDW1/PAc6ihBRnodIfZDwccxQN3n1t74wduzaz74m4ZMHZnB06567Q== +"@rozzzly/custom-electron-titlebar@^3.3.1": + version "3.3.1" + resolved "https://registry.yarnpkg.com/@rozzzly/custom-electron-titlebar/-/custom-electron-titlebar-3.3.1.tgz#1900604ac9f8b818f8fc69f7bd45addab818acdd" + integrity sha512-TshwwVRYydmrzU/7VKYeEPY7Xgf+yZcOUl3dH3AkZ+Iqmyyb8MwzgLbY9Jc6lAyHjbHDa0vgE3aClIsUYf4EQQ== + dependencies: + "@electron/remote" "^1.1.0" + "@sindresorhus/is@^0.14.0": version "0.14.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" @@ -2929,11 +2941,6 @@ custom-electron-prompt@^1.3.1: resolved "https://registry.yarnpkg.com/custom-electron-prompt/-/custom-electron-prompt-1.3.1.tgz#5c5c1266bb94ca618c493bdbebef2732286a06f2" integrity sha512-QKq0H87G1EQS6QEc1lNmPrMj+J/h/1F4BAcmH2UQ+JUX9MOHZKZvbuIMEdsjYHlgI42SUAcnQklJ9F18ZCAc3A== -custom-electron-titlebar@^3.2.7: - version "3.2.7" - resolved "https://registry.yarnpkg.com/custom-electron-titlebar/-/custom-electron-titlebar-3.2.7.tgz#fb249d6180cbda074b1d392bea755fa0743012a8" - integrity sha512-KO/6e3r6YflfNUOzi5QHLwkLHBP+ICtHPo70u/kUIKR8UUkDTPb4a9i19q0uDZQcjkH6oqRvFCz9wEHeEpCgxw== - dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" From c8ba85be766dc43f7f7a7073f9996769f7fc3dcd Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Tue, 14 Dec 2021 00:34:10 +0200 Subject: [PATCH 06/18] use firefox as falllback useragent --- index.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index b14d3f84..9965909c 100644 --- a/index.js +++ b/index.js @@ -165,22 +165,21 @@ 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", + mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 12.1; 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", } - app.userAgentFallback = + const userAgent = is.macOS() ? userAgents.mac : is.windows() ? userAgents.windows : userAgents.linux; + app.userAgentFallback = userAgent; + setupSongInfo(win); loadPlugins(win); From a273f6f73c057453e88a72825cb133a4bcdfebd8 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Tue, 14 Dec 2021 00:34:32 +0200 Subject: [PATCH 07/18] fix video toggle button appearing when in song mode --- plugins/video-toggle/front.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/video-toggle/front.js b/plugins/video-toggle/front.js index a4b75a96..6b216a6f 100644 --- a/plugins/video-toggle/front.js +++ b/plugins/video-toggle/front.js @@ -56,7 +56,7 @@ function changeDisplay(showVideo) { } function videoStarted() { - if (player.videoMode_) { + if (api.getPlayerResponse().videoDetails.musicVideoType !== 'MUSIC_VIDEO_TYPE_ATV') { // switch to high res thumbnail forceThumbnail($('#song-image img')); // show toggle button From 47ca6e0b1f81a6cca84bdd039f6943d85b4e6203 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Tue, 14 Dec 2021 19:22:02 +0200 Subject: [PATCH 08/18] use `session.webRequest.onBeforeSendHeaders` for useragent --- index.js | 15 ++++++++++++--- plugins/video-toggle/front.js | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 9965909c..6b65adc7 100644 --- a/index.js +++ b/index.js @@ -166,19 +166,28 @@ function createMainWindow() { app.once("browser-window-created", (event, win) => { // User agents are from https://developers.whatismybrowser.com/useragents/explore/ - + const originalUserAgent = win.webContents.userAgent; const userAgents = { mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 12.1; 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", } - const userAgent = + const updatedUserAgent = is.macOS() ? userAgents.mac : is.windows() ? userAgents.windows : userAgents.linux; - app.userAgentFallback = userAgent; + win.webContents.userAgent = updatedUserAgent; + app.userAgentFallback = updatedUserAgent; + + win.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => { + if (win.webContents.getURL().startsWith("https://accounts.google.com") && details.url.startsWith("https://accounts.google.com")){ + details.requestHeaders["User-Agent"] = originalUserAgent; + } + cb({ requestHeaders: details.requestHeaders }); + }); + setupSongInfo(win); loadPlugins(win); diff --git a/plugins/video-toggle/front.js b/plugins/video-toggle/front.js index 6b216a6f..1c35ce4a 100644 --- a/plugins/video-toggle/front.js +++ b/plugins/video-toggle/front.js @@ -98,7 +98,7 @@ function moveVolumeHud(showVideo) { function observeThumbnail() { const playbackModeObserver = new MutationObserver(mutations => { - if (!$('#player').videoMode_) return; + if (!player.videoMode_) return; mutations.forEach(mutation => { if (!mutation.target.src.startsWith('data:')) return; From 3764ce9a7ca79b7142de5ac52af71281832a73b0 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Thu, 16 Dec 2021 18:01:11 +0200 Subject: [PATCH 09/18] update custom-electron-titlebar --- package.json | 3 +-- plugins/in-app-menu/front.js | 2 +- yarn.lock | 20 +++++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index bdf72a1e..d98e8219 100644 --- a/package.json +++ b/package.json @@ -67,12 +67,11 @@ "@electron/remote": "^2.0.1", "@ffmpeg/core": "^0.10.0", "@ffmpeg/ffmpeg": "^0.10.0", - "@rozzzly/custom-electron-titlebar": "^3.3.1", "async-mutex": "^0.3.2", "browser-id3-writer": "^4.4.0", "chokidar": "^3.5.2", "custom-electron-prompt": "^1.3.1", - "custom-electron-titlebar": "^3.2.7", + "custom-electron-titlebar": "^3.2.9", "discord-rpc": "^3.2.0", "electron-better-web-request": "^1.0.1", "electron-debug": "^3.2.0", diff --git a/plugins/in-app-menu/front.js b/plugins/in-app-menu/front.js index a345f39c..f576f588 100644 --- a/plugins/in-app-menu/front.js +++ b/plugins/in-app-menu/front.js @@ -2,7 +2,7 @@ const { ipcRenderer } = require("electron"); const { Menu } = require("@electron/remote"); -const customTitlebar = require("@rozzzly/custom-electron-titlebar"); +const customTitlebar = require("custom-electron-titlebar"); function $(selector) { return document.querySelector(selector); } module.exports = () => { diff --git a/yarn.lock b/yarn.lock index 5371d4e1..290eed8f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1370,13 +1370,6 @@ resolved "https://registry.yarnpkg.com/@remusao/trie/-/trie-1.4.1.tgz#755d09f8a007476334e611f42719b2d581f00720" integrity sha512-yvwa+aCyYI/UjeD39BnpMypG8N06l86wIDW1/PAc6ihBRnodIfZDwccxQN3n1t74wduzaz74m4ZMHZnB06567Q== -"@rozzzly/custom-electron-titlebar@^3.3.1": - version "3.3.1" - resolved "https://registry.yarnpkg.com/@rozzzly/custom-electron-titlebar/-/custom-electron-titlebar-3.3.1.tgz#1900604ac9f8b818f8fc69f7bd45addab818acdd" - integrity sha512-TshwwVRYydmrzU/7VKYeEPY7Xgf+yZcOUl3dH3AkZ+Iqmyyb8MwzgLbY9Jc6lAyHjbHDa0vgE3aClIsUYf4EQQ== - dependencies: - "@electron/remote" "^1.1.0" - "@sindresorhus/is@^0.14.0": version "0.14.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" @@ -1605,6 +1598,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.44.tgz#df7503e6002847b834371c004b372529f3f85215" integrity sha512-+gaugz6Oce6ZInfI/tK4Pq5wIIkJMEJUu92RB3Eu93mtj4wjjjz9EB5mLp5s1pSsLXdC/CPut/xF20ZzAQJbTA== +"@types/node@^17.0.0": + version "17.0.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.0.tgz#62797cee3b8b497f6547503b2312254d4fe3c2bb" + integrity sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -2941,6 +2939,14 @@ custom-electron-prompt@^1.3.1: resolved "https://registry.yarnpkg.com/custom-electron-prompt/-/custom-electron-prompt-1.3.1.tgz#5c5c1266bb94ca618c493bdbebef2732286a06f2" integrity sha512-QKq0H87G1EQS6QEc1lNmPrMj+J/h/1F4BAcmH2UQ+JUX9MOHZKZvbuIMEdsjYHlgI42SUAcnQklJ9F18ZCAc3A== +custom-electron-titlebar@^3.2.9: + version "3.2.9" + resolved "https://registry.yarnpkg.com/custom-electron-titlebar/-/custom-electron-titlebar-3.2.9.tgz#382e889315ba76edd7f2acdd1f7f32e46848ad4a" + integrity sha512-kWMUrpYWq0LAikwMbn7rx3SHcr1RpEfYO3aju/FcMzoQbiaaAsc55EiEVB0eyp9VGWAmOqakFtkObpCa4kp9Mg== + dependencies: + "@electron/remote" "^1.1.0" + "@types/node" "^17.0.0" + dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" From 49edbf723f7b119333fc9bbc9bd6a0f435061f5e Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Thu, 16 Dec 2021 18:28:49 +0200 Subject: [PATCH 10/18] fix custom-electron-prompt & remote --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d98e8219..9bb05900 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "async-mutex": "^0.3.2", "browser-id3-writer": "^4.4.0", "chokidar": "^3.5.2", - "custom-electron-prompt": "^1.3.1", + "custom-electron-prompt": "^1.4.0", "custom-electron-titlebar": "^3.2.9", "discord-rpc": "^3.2.0", "electron-better-web-request": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index 290eed8f..b8698332 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2934,10 +2934,10 @@ cssstyle@^2.3.0: dependencies: cssom "~0.3.6" -custom-electron-prompt@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/custom-electron-prompt/-/custom-electron-prompt-1.3.1.tgz#5c5c1266bb94ca618c493bdbebef2732286a06f2" - integrity sha512-QKq0H87G1EQS6QEc1lNmPrMj+J/h/1F4BAcmH2UQ+JUX9MOHZKZvbuIMEdsjYHlgI42SUAcnQklJ9F18ZCAc3A== +custom-electron-prompt@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/custom-electron-prompt/-/custom-electron-prompt-1.4.0.tgz#04d261372807b87ec07ed12e990306d5debd5667" + integrity sha512-tqDa3yDILVI3xxwNRW1m2fyQgdMYtFcnl1d3uMx8Tt6sQ9zG+Y4n/ie4VbttQaq7dJvFCu9K3JX65K8hfaSf1g== custom-electron-titlebar@^3.2.9: version "3.2.9" From baeebd195962ccb8ea966ee2de4fbe6720f709c7 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Thu, 16 Dec 2021 19:15:55 +0200 Subject: [PATCH 11/18] downloader fixes * --experimental-wasm-bulk-memory * SharedArrayBuffer * getFolder from front * ytdl-core 4.9.2 --- index.js | 3 ++- package.json | 2 +- plugins/downloader/utils.js | 4 +--- plugins/downloader/youtube-dl.js | 5 +++-- yarn.lock | 18 +++++++++--------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 6b65adc7..6fcd2aa1 100644 --- a/index.js +++ b/index.js @@ -26,8 +26,9 @@ const app = electron.app; app.commandLine.appendSwitch( "js-flags", // WebAssembly flags - "--experimental-wasm-threads --experimental-wasm-bulk-memory" + "--experimental-wasm-threads" ); +app.commandLine.appendSwitch('enable-features', "SharedArrayBuffer"); // Fix downloader bug app.allowRendererProcessReuse = true; // https://github.com/electron/electron/issues/18397 if (config.get("options.disableHardwareAcceleration")) { if (is.dev()) { diff --git a/package.json b/package.json index 9bb05900..f4a1c97f 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "mpris-service": "^2.1.2", "node-fetch": "^2.6.6", "node-notifier": "^9.0.1", - "ytdl-core": "^4.9.1", + "ytdl-core": "^4.9.2", "ytpl": "^2.2.3" }, "devDependencies": { diff --git a/plugins/downloader/utils.js b/plugins/downloader/utils.js index 88eeba01..40e5969f 100644 --- a/plugins/downloader/utils.js +++ b/plugins/downloader/utils.js @@ -1,8 +1,6 @@ const electron = require("electron"); -//const remote = require('@electron/remote'); -module.exports.getFolder = (customFolder) => - customFolder || electron.app.getPath("downloads"); +module.exports.getFolder = customFolder => customFolder || electron.app.getPath("downloads"); module.exports.defaultMenuDownloadLabel = "Download playlist"; const orderedQualityList = ["maxresdefault", "hqdefault", "mqdefault", "sdddefault"]; diff --git a/plugins/downloader/youtube-dl.js b/plugins/downloader/youtube-dl.js index 906fc35c..345f3ff2 100644 --- a/plugins/downloader/youtube-dl.js +++ b/plugins/downloader/youtube-dl.js @@ -3,6 +3,7 @@ const { join } = require("path"); const Mutex = require("async-mutex").Mutex; const { ipcRenderer } = require("electron"); +const remote = require('@electron/remote'); const is = require("electron-is"); const filenamify = require("filenamify"); @@ -14,7 +15,7 @@ const ytdl = require("ytdl-core"); const { triggerAction, triggerActionSync } = require("../utils"); const { ACTIONS, CHANNEL } = require("./actions.js"); -const { getFolder, urlToJPG } = require("./utils"); +const { urlToJPG } = require("./utils"); const { cleanupName } = require("../../providers/song-info"); const { createFFmpeg } = FFmpeg; @@ -135,7 +136,7 @@ const toMP3 = async ( safeVideoName + "." + extension ); - const folder = getFolder(options.downloadFolder); + const folder = options.downloadFolder || remote.app.getPath("downloads"); const name = metadata.title ? `${metadata.artist ? `${metadata.artist} - ` : ""}${metadata.title}` : videoName; diff --git a/yarn.lock b/yarn.lock index b8698332..c25ed838 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6243,10 +6243,10 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" -m3u8stream@^0.8.3: - version "0.8.3" - resolved "https://registry.yarnpkg.com/m3u8stream/-/m3u8stream-0.8.3.tgz#c4624e92b4240eb356d040c4a5e155586cf58108" - integrity sha512-0nAcdrF8YJKUkb6PzWdvGftTPyCVWgoiot1AkNVbPKTeIGsWs6DrOjifrJ0Zi8WQfQmD2SuVCjkYIOip12igng== +m3u8stream@^0.8.4: + version "0.8.4" + resolved "https://registry.yarnpkg.com/m3u8stream/-/m3u8stream-0.8.4.tgz#15b49d0c2b510755ea43c1e53f85d7aaa4dc65c2" + integrity sha512-sco80Db+30RvcaIOndenX6E6oQNgTiBKeJbFPc+yDXwPQIkryfboEbCvXPlBRq3mQTCVPQO93TDVlfRwqpD35w== dependencies: miniget "^4.0.0" sax "^1.2.4" @@ -8921,12 +8921,12 @@ yocto-queue@^1.0.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-1.0.0.tgz#7f816433fb2cbc511ec8bf7d263c3b58a1a3c251" integrity sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g== -ytdl-core@^4.9.1: - version "4.9.1" - resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.9.1.tgz#f587e2bd8329b5133c0bac4ce5ee1f3c7a1175a9" - integrity sha512-6Jbp5RDhUEozlaJQAR+l8oV8AHsx3WUXxSyPxzE6wOIAaLql7Hjiy0ZM58wZoyj1YEenlEPjEqcJIjKYKxvHtQ== +ytdl-core@^4.9.2: + version "4.9.2" + resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.9.2.tgz#c2d1ec44ee3cabff35e5843c6831755e69ffacf0" + integrity sha512-aTlsvsN++03MuOtyVD4DRF9Z/9UAeeuiNbjs+LjQBAiw4Hrdp48T3U9vAmRPyvREzupraY8pqRoBfKGqpq+eHA== dependencies: - m3u8stream "^0.8.3" + m3u8stream "^0.8.4" miniget "^4.0.0" sax "^1.1.3" From 8f2ed3039a5f30eeaf372afc4bcb1105b080bee9 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Thu, 16 Dec 2021 19:29:09 +0200 Subject: [PATCH 12/18] add comment to useragent fix --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 6fcd2aa1..c1437847 100644 --- a/index.js +++ b/index.js @@ -183,6 +183,7 @@ app.once("browser-window-created", (event, win) => { app.userAgentFallback = updatedUserAgent; win.webContents.session.webRequest.onBeforeSendHeaders((details, cb) => { + // this will only happen if login failed, and "retry" was pressed if (win.webContents.getURL().startsWith("https://accounts.google.com") && details.url.startsWith("https://accounts.google.com")){ details.requestHeaders["User-Agent"] = originalUserAgent; } From 7c6fe6748e07de28b8961e96cc13355cab35c490 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Sat, 18 Dec 2021 11:02:24 +0000 Subject: [PATCH 13/18] fix: upgrade electron-updater from 4.6.2 to 4.6.3 Snyk has created this PR to upgrade electron-updater from 4.6.2 to 4.6.3. See this package in npm: See this project in Snyk: https://app.snyk.io/org/th-ch/project/81809c53-bb7b-46b9-a0d7-806d45d74ac6?utm_source=github&utm_medium=referral&page=upgrade-pr --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2a0dc519..5d37e3a5 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "electron-localshortcut": "^3.2.1", "electron-store": "^7.0.3", "electron-unhandled": "^3.0.2", - "electron-updater": "^4.6.1", + "electron-updater": "^4.6.3", "filenamify": "^4.3.0", "hark": "^1.2.3", "md5": "^2.3.0", diff --git a/yarn.lock b/yarn.lock index 19f566db..f5f22d36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3398,10 +3398,10 @@ electron-unhandled@^3.0.2: ensure-error "^2.0.0" lodash.debounce "^4.0.8" -electron-updater@^4.6.1: - version "4.6.2" - resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-4.6.2.tgz#6edd2816a6b3859f55252082f59308b0d314f644" - integrity sha512-KAloJQNXwW2j81n0o2KgBsiRsxp2OS15nty4nZLUjZYNuRyJ7yp2zeKPL4fVNGY6Ave491ht7/Dyz5OIykJf9g== +electron-updater@^4.6.3: + version "4.6.5" + resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-4.6.5.tgz#e9a75458bbfd6bb41a58a829839e150ad2eb2d3d" + integrity sha512-kdTly8O9mSZfm9fslc1mnCY+mYOeaYRy7ERa2Fed240u01BKll3aiupzkd07qKw69KvhBSzuHroIW3mF0D8DWA== dependencies: "@types/semver" "^7.3.6" builder-util-runtime "8.9.2" From 02a989ca0770e5220d76b35b689d44f440778c1a Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Sat, 18 Dec 2021 21:03:32 +0200 Subject: [PATCH 14/18] fix unnecessary skips --- plugins/skip-silences/front.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/skip-silences/front.js b/plugins/skip-silences/front.js index 792851c2..d7a8514c 100644 --- a/plugins/skip-silences/front.js +++ b/plugins/skip-silences/front.js @@ -6,7 +6,7 @@ module.exports = () => { document.addEventListener("apiLoaded", (apiEvent) => { const video = document.querySelector("video"); const speechEvents = hark(video, { - threshold: -90, // dB (-100 = absolute silence, 0 = loudest) + threshold: -100, // dB (-100 = absolute silence, 0 = loudest) interval: 2, // ms }); const skipSilence = () => { @@ -19,9 +19,11 @@ module.exports = () => { isSilent = false; }); - speechEvents.on("stopped_speaking", function () { - isSilent = true; - skipSilence(); + speechEvents.on("stopped_speaking", function () { + if (!(video.paused || video.seeking || video.ended)) { + isSilent = true; + skipSilence(); + } }); video.addEventListener("play", function () { From 5fbc0f8122313e2aec1865ffa93fc57863766d87 Mon Sep 17 00:00:00 2001 From: Mulverine Date: Thu, 23 Dec 2021 11:36:11 -0700 Subject: [PATCH 15/18] Add album art/thumbnail to discord activity --- plugins/discord/back.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/discord/back.js b/plugins/discord/back.js index 2106c744..7c91064f 100644 --- a/plugins/discord/back.js +++ b/plugins/discord/back.js @@ -103,7 +103,7 @@ module.exports = (win, { activityTimoutEnabled, activityTimoutTime, listenAlong type: 2, // Listening, addressed in https://github.com/discordjs/RPC/pull/149 details: songInfo.title, state: songInfo.artist, - largeImageKey: "logo", + largeImageKey: songInfo.imageSrc, largeImageText: [ songInfo.uploadDate, songInfo.views.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " views", From ed7025b4a26146b5d7a477f34552708584a5ee39 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Fri, 24 Dec 2021 01:58:15 +0200 Subject: [PATCH 16/18] fix precise-volume options sync --- plugins/precise-volume/front.js | 58 +++++++++++++-------------------- plugins/precise-volume/menu.js | 28 +++++++++------- 2 files changed, 38 insertions(+), 48 deletions(-) diff --git a/plugins/precise-volume/front.js b/plugins/precise-volume/front.js index 189a20eb..0fec2787 100644 --- a/plugins/precise-volume/front.js +++ b/plugins/precise-volume/front.js @@ -34,6 +34,14 @@ function firstRun(options) { if (!noVid) { setupVideoPlayerOnwheel(options); } + + // Change options from renderer to keep sync + ipcRenderer.on("setOptions", (_event, newOptions = {}) => { + for (option in newOptions) { + options[option] = newOptions[option]; + } + setOptions("precise-volume", options); + }); } function injectVolumeHud(noVid) { @@ -93,7 +101,7 @@ function writeOptions(options) { writeTimeout = setTimeout(() => { setOptions("precise-volume", options); writeTimeout = null; - }, 1500) + }, 1000) } /** Add onwheel event to play bar and also track if play bar is hovered*/ @@ -142,7 +150,7 @@ function setupSliderObserver(options) { /** if (toIncrease = false) then volume decrease */ function changeVolume(toIncrease, options) { // Apply volume change if valid - const steps = (options.steps || 1); + const steps = Number(options.steps || 1); api.setVolume(toIncrease ? Math.min(api.getVolume() + steps, 100) : Math.max(api.getVolume() - steps, 0)); @@ -211,39 +219,17 @@ function setupGlobalShortcuts(options) { function setupLocalArrowShortcuts(options) { if (options.arrowsShortcut) { - addListener(); - } - - // Change options from renderer to keep sync - ipcRenderer.on("setArrowsShortcut", (_event, isEnabled) => { - options.arrowsShortcut = isEnabled; - setOptions("precise-volume", options); - // This allows changing this setting without restarting app - if (isEnabled) { - addListener(); - } else { - removeListener(); - } - }); - - function addListener() { - window.addEventListener('keydown', callback); - } - - function removeListener() { - window.removeEventListener("keydown", callback); - } - - function callback(event) { - switch (event.code) { - case "ArrowUp": - event.preventDefault(); - changeVolume(true, options); - break; - case "ArrowDown": - event.preventDefault(); - changeVolume(false, options); - break; - } + window.addEventListener('keydown', (event) => { + switch (event.code) { + case "ArrowUp": + event.preventDefault(); + changeVolume(true, options); + break; + case "ArrowDown": + event.preventDefault(); + changeVolume(false, options); + break; + } + }); } } diff --git a/plugins/precise-volume/menu.js b/plugins/precise-volume/menu.js index 06ee84b9..c3d56f8f 100644 --- a/plugins/precise-volume/menu.js +++ b/plugins/precise-volume/menu.js @@ -3,6 +3,17 @@ const { setOptions } = require("../../config/plugins"); const prompt = require("custom-electron-prompt"); const promptOptions = require("../../providers/prompt-options"); +function changeOptions(changedOptions, options, win) { + for (option in changedOptions) { + options[option] = changedOptions[option]; + } + // Dynamically change setting if plugin is enabled + if (enabled()) { + win.webContents.send("setOptions", changedOptions); + } else { // Fallback to usual method if disabled + setOptions("precise-volume", options); + } +} module.exports = (win, options) => [ { @@ -10,13 +21,7 @@ module.exports = (win, options) => [ type: "checkbox", checked: !!options.arrowsShortcut, click: item => { - // Dynamically change setting if plugin is enabled - if (enabled()) { - win.webContents.send("setArrowsShortcut", item.checked); - } else { // Fallback to usual method if disabled - options.arrowsShortcut = item.checked; - setOptions("precise-volume", options); - } + changeOptions({ arrowsShortcut: item.checked }, options, win); } }, { @@ -46,8 +51,7 @@ async function promptVolumeSteps(win, options) { }, win) if (output || output === 0) { // 0 is somewhat valid - options.steps = output; - setOptions("precise-volume", options); + changeOptions({ steps: output}, options, win); } } @@ -64,11 +68,11 @@ async function promptGlobalShortcuts(win, options, item) { }, win) if (output) { + let newGlobalShortcuts = {}; for (const { value, accelerator } of output) { - options.globalShortcuts[value] = accelerator; + newGlobalShortcuts[value] = accelerator; } - - setOptions("precise-volume", options); + changeOptions({ globalShortcuts: newGlobalShortcuts }, options, win); item.checked = !!options.globalShortcuts.volumeUp || !!options.globalShortcuts.volumeDown; } else { From 4d4ac5648666ef36cdd2f95713eac93c5b6c6128 Mon Sep 17 00:00:00 2001 From: TC Date: Thu, 30 Dec 2021 14:58:21 +0100 Subject: [PATCH 17/18] Ensure NODE_OPTIONS are unset in dev mode to avoid warning --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5c67cc60..24f2af68 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ }, "scripts": { "test": "jest", - "start": "electron .", + "start": "NODE_OPTIONS= electron .", "start:debug": "ELECTRON_ENABLE_LOGGING=1 electron .", "icon": "rimraf assets/generated && electron-icon-maker --input=assets/youtube-music.png --output=assets/generated", "generate:package": "node utils/generate-package-json.js", From 33faa2deb38428903379a7a8286ffdf8a40e2b12 Mon Sep 17 00:00:00 2001 From: TC Date: Thu, 30 Dec 2021 14:59:11 +0100 Subject: [PATCH 18/18] nit: improve comment for shared Array Buffer --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index c1437847..af520692 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,7 @@ app.commandLine.appendSwitch( // WebAssembly flags "--experimental-wasm-threads" ); -app.commandLine.appendSwitch('enable-features', "SharedArrayBuffer"); // Fix downloader bug +app.commandLine.appendSwitch("enable-features", "SharedArrayBuffer"); // Required for downloader app.allowRendererProcessReuse = true; // https://github.com/electron/electron/issues/18397 if (config.get("options.disableHardwareAcceleration")) { if (is.dev()) {