mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
update electron & remote module
This commit is contained in:
28
index.js
28
index.js
@ -2,6 +2,8 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const electron = require("electron");
|
const electron = require("electron");
|
||||||
|
const remote = require('@electron/remote/main');
|
||||||
|
remote.initialize();
|
||||||
const enhanceWebRequest = require("electron-better-web-request").default;
|
const enhanceWebRequest = require("electron-better-web-request").default;
|
||||||
const is = require("electron-is");
|
const is = require("electron-is");
|
||||||
const unhandled = require("electron-unhandled");
|
const unhandled = require("electron-unhandled");
|
||||||
@ -98,7 +100,6 @@ function createMainWindow() {
|
|||||||
preload: path.join(__dirname, "preload.js"),
|
preload: path.join(__dirname, "preload.js"),
|
||||||
nodeIntegrationInSubFrames: true,
|
nodeIntegrationInSubFrames: true,
|
||||||
nativeWindowOpen: true, // window.open return Window object(like in regular browsers), not BrowserWindowProxy
|
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
|
affinity: "main-window", // main window, and addition windows should work in one process
|
||||||
...(isTesting()
|
...(isTesting()
|
||||||
? {
|
? {
|
||||||
@ -116,6 +117,7 @@ function createMainWindow() {
|
|||||||
: "default",
|
: "default",
|
||||||
autoHideMenuBar: config.get("options.hideMenu"),
|
autoHideMenuBar: config.get("options.hideMenu"),
|
||||||
});
|
});
|
||||||
|
remote.enable(win.webContents);
|
||||||
if (windowPosition) {
|
if (windowPosition) {
|
||||||
const { x, y } = windowPosition;
|
const { x, y } = windowPosition;
|
||||||
win.setPosition(x, y);
|
win.setPosition(x, y);
|
||||||
@ -197,34 +199,22 @@ app.once("browser-window-created", (event, win) => {
|
|||||||
event.preventDefault();
|
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 = {
|
const userAgents = {
|
||||||
mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 12.0; rv:95.0) Gecko/20100101 Firefox/95.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",
|
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",
|
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.macOS() ? userAgents.mac :
|
||||||
is.windows() ? userAgents.windows :
|
is.windows() ? userAgents.windows :
|
||||||
userAgents.linux;
|
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(
|
win.webContents.on(
|
||||||
"new-window",
|
"new-window",
|
||||||
(e, url, frameName, disposition, options) => {
|
(e, url, frameName, disposition, options) => {
|
||||||
|
|||||||
@ -64,12 +64,13 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cliqz/adblocker-electron": "^1.23.0",
|
"@cliqz/adblocker-electron": "^1.23.0",
|
||||||
|
"@electron/remote": "^2.0.1",
|
||||||
"@ffmpeg/core": "^0.10.0",
|
"@ffmpeg/core": "^0.10.0",
|
||||||
"@ffmpeg/ffmpeg": "^0.10.0",
|
"@ffmpeg/ffmpeg": "^0.10.0",
|
||||||
"async-mutex": "^0.3.2",
|
"async-mutex": "^0.3.2",
|
||||||
"browser-id3-writer": "^4.4.0",
|
"browser-id3-writer": "^4.4.0",
|
||||||
"custom-electron-prompt": "^1.3.1",
|
|
||||||
"chokidar": "^3.5.2",
|
"chokidar": "^3.5.2",
|
||||||
|
"custom-electron-prompt": "^1.3.1",
|
||||||
"custom-electron-titlebar": "^3.2.7",
|
"custom-electron-titlebar": "^3.2.7",
|
||||||
"discord-rpc": "^3.2.0",
|
"discord-rpc": "^3.2.0",
|
||||||
"electron-better-web-request": "^1.0.1",
|
"electron-better-web-request": "^1.0.1",
|
||||||
@ -88,7 +89,7 @@
|
|||||||
"ytpl": "^2.2.3"
|
"ytpl": "^2.2.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^12.2.2",
|
"electron": "^16.0.2",
|
||||||
"electron-builder": "^22.10.5",
|
"electron-builder": "^22.10.5",
|
||||||
"electron-devtools-installer": "^3.1.1",
|
"electron-devtools-installer": "^3.1.1",
|
||||||
"electron-icon-maker": "0.0.5",
|
"electron-icon-maker": "0.0.5",
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
const electron = require("electron");
|
const electron = require("electron");
|
||||||
|
//const remote = require('@electron/remote');
|
||||||
|
|
||||||
module.exports.getFolder = (customFolder) =>
|
module.exports.getFolder = (customFolder) =>
|
||||||
customFolder || (electron.app || electron.remote.app).getPath("downloads");
|
customFolder || electron.app.getPath("downloads");
|
||||||
module.exports.defaultMenuDownloadLabel = "Download playlist";
|
module.exports.defaultMenuDownloadLabel = "Download playlist";
|
||||||
|
|
||||||
const orderedQualityList = ["maxresdefault", "hqdefault", "mqdefault", "sdddefault"];
|
const orderedQualityList = ["maxresdefault", "hqdefault", "mqdefault", "sdddefault"];
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
const { remote, ipcRenderer } = require("electron");
|
const { ipcRenderer } = require("electron");
|
||||||
|
const { Menu } = require("@electron/remote");
|
||||||
|
|
||||||
|
|
||||||
const customTitlebar = require("custom-electron-titlebar");
|
const customTitlebar = require("custom-electron-titlebar");
|
||||||
function $(selector) { return document.querySelector(selector); }
|
function $(selector) { return document.querySelector(selector); }
|
||||||
@ -12,7 +14,7 @@ module.exports = () => {
|
|||||||
document.title = "Youtube Music";
|
document.title = "Youtube Music";
|
||||||
|
|
||||||
ipcRenderer.on("updateMenu", function (_event, showMenu) {
|
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)
|
// Increases the right margin of Navbar background when the scrollbar is visible to avoid blocking it (z-index doesn't affect it)
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
const { ipcRenderer, remote } = require("electron");
|
const { ipcRenderer } = require("electron");
|
||||||
|
const { globalShortcut } = require('@electron/remote');
|
||||||
|
|
||||||
const { setOptions } = require("../../config/plugins");
|
const { setOptions } = require("../../config/plugins");
|
||||||
|
|
||||||
@ -202,10 +203,10 @@ function setTooltip(volume) {
|
|||||||
|
|
||||||
function setupGlobalShortcuts(options) {
|
function setupGlobalShortcuts(options) {
|
||||||
if (options.globalShortcuts.volumeUp) {
|
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) {
|
if (options.globalShortcuts.volumeDown) {
|
||||||
remote.globalShortcut.register((options.globalShortcuts.volumeDown), () => changeVolume(false, options));
|
globalShortcut.register((options.globalShortcuts.volumeDown), () => changeVolume(false, options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
const { ElementFromFile, templatePath } = require("../utils");
|
const { ElementFromFile, templatePath } = require("../utils");
|
||||||
const dialog = require('electron').remote.dialog
|
const { dialog } = require('@electron/remote');
|
||||||
|
|
||||||
function $(selector) { return document.querySelector(selector); }
|
function $(selector) { return document.querySelector(selector); }
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const { remote } = require("electron");
|
const remote = require('@electron/remote');
|
||||||
|
|
||||||
const config = require("./config");
|
const config = require("./config");
|
||||||
const { fileExists } = require("./plugins/utils");
|
const { fileExists } = require("./plugins/utils");
|
||||||
|
|||||||
45
yarn.lock
45
yarn.lock
@ -700,7 +700,7 @@
|
|||||||
ajv "^6.12.0"
|
ajv "^6.12.0"
|
||||||
ajv-keywords "^3.4.1"
|
ajv-keywords "^3.4.1"
|
||||||
|
|
||||||
"@electron/get@^1.0.1", "@electron/get@^1.12.4":
|
"@electron/get@^1.12.4":
|
||||||
version "1.12.4"
|
version "1.12.4"
|
||||||
resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.12.4.tgz#a5971113fc1bf8fa12a8789dc20152a7359f06ab"
|
resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.12.4.tgz#a5971113fc1bf8fa12a8789dc20152a7359f06ab"
|
||||||
integrity sha512-6nr9DbJPUR9Xujw6zD3y+rS95TyItEVM0NVjt1EehY2vUWfIgPiIPVHxCvaTS0xr2B+DRxovYVKbuOWqC35kjg==
|
integrity sha512-6nr9DbJPUR9Xujw6zD3y+rS95TyItEVM0NVjt1EehY2vUWfIgPiIPVHxCvaTS0xr2B+DRxovYVKbuOWqC35kjg==
|
||||||
@ -716,11 +716,32 @@
|
|||||||
global-agent "^2.0.2"
|
global-agent "^2.0.2"
|
||||||
global-tunnel-ng "^2.7.1"
|
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":
|
"@electron/remote@^1.0.4":
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-1.1.0.tgz#167d119c7c03c7778b556fdc4f1f38a44b23f1c2"
|
resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-1.1.0.tgz#167d119c7c03c7778b556fdc4f1f38a44b23f1c2"
|
||||||
integrity sha512-yr8gZTkIgJYKbFqExI4QZqMSjn1kL/us9Dl46+TH1EZdhgRtsJ6HDfdsIxu0QEc6Hv+DMAXs69rgquH+8FDk4w==
|
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":
|
"@electron/universal@1.0.5":
|
||||||
version "1.0.5"
|
version "1.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/@electron/universal/-/universal-1.0.5.tgz#b812340e4ef21da2b3ee77b2b4d35c9b86defe37"
|
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"
|
lodash.isequal "^4.5.0"
|
||||||
semver "^7.3.5"
|
semver "^7.3.5"
|
||||||
|
|
||||||
electron@^12.2.2:
|
electron@^16.0.2:
|
||||||
version "12.2.2"
|
version "16.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/electron/-/electron-12.2.2.tgz#9627594d6b5bb589f00355989d316b6542539e54"
|
resolved "https://registry.yarnpkg.com/electron/-/electron-16.0.4.tgz#87dfe21d17608537fc6df292c437362297566a73"
|
||||||
integrity sha512-Oma/nIfvgql9JjAxdB9gQk//qxpJaI6PgMocYMiW4kFyLi+8jS6oGn33QG3FESS//cw09KRnWmA9iutuFAuXtw==
|
integrity sha512-IptwmowvMP1SFOmZLh6rrURwfnOxbDBXBRBcaOdfBM5I+B9mgtdNwzNC3ymFFNzEkZUwdOyg9fu3iyjAAQIQgw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@electron/get" "^1.0.1"
|
"@electron/get" "^1.13.0"
|
||||||
"@types/node" "^14.6.2"
|
"@types/node" "^14.6.2"
|
||||||
extract-zip "^1.0.3"
|
extract-zip "^1.0.3"
|
||||||
|
|
||||||
@ -4395,6 +4416,18 @@ global-agent@^2.0.2:
|
|||||||
semver "^7.3.2"
|
semver "^7.3.2"
|
||||||
serialize-error "^7.0.1"
|
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:
|
global-dirs@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-3.0.0.tgz#70a76fe84ea315ab37b1f5576cbde7d48ef72686"
|
resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-3.0.0.tgz#70a76fe84ea315ab37b1f5576cbde7d48ef72686"
|
||||||
|
|||||||
Reference in New Issue
Block a user