From 719c244e3221c857bcf57669c8202903f46d7e26 Mon Sep 17 00:00:00 2001
From: Araxeus <78568641+Araxeus@users.noreply.github.com>
Date: Tue, 9 Nov 2021 10:01:33 +0200
Subject: [PATCH 01/10] fix #472
---
plugins/discord/back.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/discord/back.js b/plugins/discord/back.js
index 9dc6f9fe..2106c744 100644
--- a/plugins/discord/back.js
+++ b/plugins/discord/back.js
@@ -1,6 +1,6 @@
const Discord = require("discord-rpc");
const { dev } = require("electron-is");
-const { dialog } = require("electron");
+const { dialog, app } = require("electron");
const registerCallback = require("../../providers/song-info");
@@ -70,7 +70,7 @@ let clearActivity;
*/
let updateActivity;
-module.exports = (win, {activityTimoutEnabled, activityTimoutTime, listenAlong}) => {
+module.exports = (win, { activityTimoutEnabled, activityTimoutTime, listenAlong }) => {
window = win;
// We get multiple events
// Next song: PAUSE(n), PAUSE(n+1), PLAY(n+1)
@@ -136,7 +136,7 @@ module.exports = (win, {activityTimoutEnabled, activityTimoutTime, listenAlong})
registerCallback(updateActivity);
connect();
});
- win.on("close", () => module.exports.clear());
+ app.on('window-all-closed', module.exports.clear)
};
module.exports.clear = () => {
From bbece751c0b5c8e78bbc1dcc5455eb190c219a8a Mon Sep 17 00:00:00 2001
From: Araxeus <78568641+Araxeus@users.noreply.github.com>
Date: Tue, 9 Nov 2021 10:03:06 +0200
Subject: [PATCH 02/10] lint playback speed
---
plugins/playback-speed/front.js | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/plugins/playback-speed/front.js b/plugins/playback-speed/front.js
index f1ea78e8..9ea63d0b 100644
--- a/plugins/playback-speed/front.js
+++ b/plugins/playback-speed/front.js
@@ -5,15 +5,13 @@ function $(selector) { return document.querySelector(selector); }
const slider = ElementFromFile(templatePath(__dirname, "slider.html"));
-const roundToTwo = (n) => Math.round(n * 1e2) / 1e2;
+const roundToTwo = n => Math.round(n * 1e2) / 1e2;
const MIN_PLAYBACK_SPEED = 0.07;
const MAX_PLAYBACK_SPEED = 16;
let playbackSpeed = 1;
-const computePlayBackSpeed = (playbackSpeedPercentage) => playbackSpeedPercentage || MIN_PLAYBACK_SPEED;
-
const updatePlayBackSpeed = () => {
$('video').playbackRate = playbackSpeed;
@@ -71,8 +69,8 @@ const setupWheelListener = () => {
}
function setupSliderListener() {
- $('#playback-speed-slider').addEventListener('immediate-value-changed', () => {
- playbackSpeed = computePlayBackSpeed($('#playback-speed-slider #sliderBar').value);
+ $('#playback-speed-slider').addEventListener('immediate-value-changed', e => {
+ playbackSpeed = e.detail.value || MIN_PLAYBACK_SPEED;
if (isNaN(playbackSpeed)) {
playbackSpeed = 1;
}
From eafdd5046dcc1581335d243d9ef931d6fa3410ca Mon Sep 17 00:00:00 2001
From: Araxeus <78568641+Araxeus@users.noreply.github.com>
Date: Tue, 9 Nov 2021 10:42:32 +0200
Subject: [PATCH 03/10] fix lyric text size
---
plugins/lyrics-genius/style.css | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/plugins/lyrics-genius/style.css b/plugins/lyrics-genius/style.css
index 7807a814..705c20fa 100644
--- a/plugins/lyrics-genius/style.css
+++ b/plugins/lyrics-genius/style.css
@@ -5,3 +5,8 @@
pointer-events: none;
text-decoration: none;
}
+
+#contents.genius-lyrics {
+ font-size: initial;
+ opacity: 0.9;
+}
\ No newline at end of file
From 72b43980241671bde22a2fe7f48e62f20962d732 Mon Sep 17 00:00:00 2001
From: Araxeus <78568641+Araxeus@users.noreply.github.com>
Date: Tue, 9 Nov 2021 15:17:26 +0200
Subject: [PATCH 04/10] lint&fix video-toggle plugin
---
plugins/video-toggle/front.js | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/plugins/video-toggle/front.js b/plugins/video-toggle/front.js
index 588642a0..8a389ce6 100644
--- a/plugins/video-toggle/front.js
+++ b/plugins/video-toggle/front.js
@@ -20,7 +20,7 @@ module.exports = (_options) => {
function setup() {
$('ytmusic-player-page').prepend(switchButtonDiv);
- $('#song-image.ytmusic-player').style.display = "block"
+ $('#song-image.ytmusic-player').style.display = "block";
if (options.hideVideo) {
$('.video-switch-button-checkbox').checked = false;
@@ -39,29 +39,35 @@ function setup() {
}
function changeDisplay(showVideo) {
- if (!showVideo && $('ytmusic-player').getAttribute('playback-mode') !== "ATV_PREFERRED") {
+ if (!showVideo) {
$('video').style.top = "0";
- $('ytmusic-player').style.margin = "auto 21.5px";
+ $('ytmusic-player').style.margin = "auto 0px";
$('ytmusic-player').setAttribute('playback-mode', "ATV_PREFERRED");
- }
-
- showVideo ?
- $('#song-video.ytmusic-player').style.display = "unset" :
$('#song-video.ytmusic-player').style.display = "none";
+ } else {
+ $('#song-video.ytmusic-player').style.display = "unset";
+ // fix black video
+ $('video').pause(); $('video').play();
+ }
}
function videoStarted() {
if (videoExist()) {
+ // switch to high res thumbnail
const thumbnails = $('#movie_player').getPlayerResponse()?.videoDetails?.thumbnail?.thumbnails;
if (thumbnails && thumbnails.length > 0) {
- $('#song-image img').src = thumbnails[thumbnails.length-1].url;
+ $('#song-image img').src = thumbnails[thumbnails.length - 1].url;
}
+ // show toggle button
switchButtonDiv.style.display = "initial";
+ // change display to video mode if video exist & video is hidden & option.hideVideo = false
if (!options.hideVideo && $('#song-video.ytmusic-player').style.display === "none") {
changeDisplay(true);
}
} else {
+ // video doesn't exist -> switch to song mode
changeDisplay(false);
+ // hide toggle button
switchButtonDiv.style.display = "none";
}
}
@@ -75,11 +81,11 @@ function videoExist() {
function forcePlaybackMode() {
const playbackModeObserver = new MutationObserver(mutations => {
mutations.forEach(mutation => {
- if (mutation.type === 'attributes' && mutation.attributeName === 'playback-mode' && mutation.target.getAttribute('playback-mode') !== "ATV_PREFERRED") {
+ if (mutation.target.getAttribute('playback-mode') !== "ATV_PREFERRED") {
playbackModeObserver.disconnect();
mutation.target.setAttribute('playback-mode', "ATV_PREFERRED");
}
});
});
- playbackModeObserver.observe($('ytmusic-player'), { attributeFilter: ["playback-mode"] })
+ playbackModeObserver.observe($('ytmusic-player'), { attributeFilter: ["playback-mode"] });
}
From 87ee7ed83de1523911f82e9861ead7c09ef35f6a Mon Sep 17 00:00:00 2001
From: Araxeus <78568641+Araxeus@users.noreply.github.com>
Date: Wed, 10 Nov 2021 22:06:03 +0200
Subject: [PATCH 05/10] lint video-toggle
---
plugins/video-toggle/front.js | 36 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/plugins/video-toggle/front.js b/plugins/video-toggle/front.js
index 8a389ce6..1c3911e3 100644
--- a/plugins/video-toggle/front.js
+++ b/plugins/video-toggle/front.js
@@ -4,7 +4,7 @@ const { setOptions } = require("../../config/plugins");
function $(selector) { return document.querySelector(selector); }
-let options;
+let options, player, video, api;
const switchButtonDiv = ElementFromFile(
templatePath(__dirname, "button_template.html")
@@ -17,7 +17,11 @@ module.exports = (_options) => {
document.addEventListener('apiLoaded', setup, { once: true, passive: true });
}
-function setup() {
+function setup(e) {
+ api = e.detail;
+ player = $('ytmusic-player');
+ video = $('video');
+
$('ytmusic-player-page').prepend(switchButtonDiv);
$('#song-image.ytmusic-player').style.display = "block";
@@ -26,6 +30,8 @@ function setup() {
$('.video-switch-button-checkbox').checked = false;
changeDisplay(false);
forcePlaybackMode();
+ // fix black video
+ video.style.height = "auto";
}
// button checked = show video
@@ -35,26 +41,20 @@ function setup() {
setOptions("video-toggle", options);
})
- $('video').addEventListener('loadedmetadata', videoStarted);
+ video.addEventListener('loadedmetadata', videoStarted);
}
function changeDisplay(showVideo) {
- if (!showVideo) {
- $('video').style.top = "0";
- $('ytmusic-player').style.margin = "auto 0px";
- $('ytmusic-player').setAttribute('playback-mode', "ATV_PREFERRED");
- $('#song-video.ytmusic-player').style.display = "none";
- } else {
- $('#song-video.ytmusic-player').style.display = "unset";
- // fix black video
- $('video').pause(); $('video').play();
- }
+ player.style.margin = showVideo ? '' : 'auto 0px';
+ player.setAttribute('playback-mode', showVideo ? 'OMV_PREFERRED' : 'ATV_PREFERRED');
+ $('#song-video.ytmusic-player').style.display = showVideo ? 'unset' : 'none';
+ if(showVideo && !video.style.top) video.style.top = `${(player.clientHeight - video.clientHeight) / 2}px`;
}
function videoStarted() {
- if (videoExist()) {
+ if (player.videoMode_) {
// switch to high res thumbnail
- const thumbnails = $('#movie_player').getPlayerResponse()?.videoDetails?.thumbnail?.thumbnails;
+ const thumbnails = api.getPlayerResponse()?.videoDetails?.thumbnail?.thumbnails;
if (thumbnails && thumbnails.length > 0) {
$('#song-image img').src = thumbnails[thumbnails.length - 1].url;
}
@@ -72,10 +72,6 @@ function videoStarted() {
}
}
-function videoExist() {
- return $('#player').videoMode_;
-}
-
// on load, after a delay, the page overrides the playback-mode to 'OMV_PREFERRED' which causes weird aspect ratio in the image container
// this function fix the problem by overriding that override :)
function forcePlaybackMode() {
@@ -87,5 +83,5 @@ function forcePlaybackMode() {
}
});
});
- playbackModeObserver.observe($('ytmusic-player'), { attributeFilter: ["playback-mode"] });
+ playbackModeObserver.observe(player, { attributeFilter: ["playback-mode"] });
}
From 071799c435dcaa69beaa15d0441c70c02d4e3c3a Mon Sep 17 00:00:00 2001
From: Araxeus <78568641+Araxeus@users.noreply.github.com>
Date: Fri, 12 Nov 2021 16:39:43 +0200
Subject: [PATCH 06/10] fix some shortcuts
---
providers/song-controls.js | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/providers/song-controls.js b/providers/song-controls.js
index 7f43df11..d4659504 100644
--- a/providers/song-controls.js
+++ b/providers/song-controls.js
@@ -13,8 +13,8 @@ module.exports = (win) => {
previous: () => pressKey(win, "k"),
next: () => pressKey(win, "j"),
playPause: () => pressKey(win, "space"),
- like: () => pressKey(win, "_"),
- dislike: () => pressKey(win, "+"),
+ like: () => pressKey(win, "+"),
+ dislike: () => pressKey(win, "_"),
go10sBack: () => pressKey(win, "h"),
go10sForward: () => pressKey(win, "l"),
go1sBack: () => pressKey(win, "h", ["shift"]),
@@ -24,8 +24,6 @@ module.exports = (win) => {
// General
volumeMinus10: () => pressKey(win, "-"),
volumePlus10: () => pressKey(win, "="),
- dislikeAndNext: () => pressKey(win, "-", ["shift"]),
- like: () => pressKey(win, "=", ["shift"]),
fullscreen: () => pressKey(win, "f"),
muteUnmute: () => pressKey(win, "m"),
maximizeMinimisePlayer: () => pressKey(win, "q"),
@@ -38,14 +36,14 @@ module.exports = (win) => {
pressKey(win, "g");
pressKey(win, "l");
},
- goToHotlist: () => {
- pressKey(win, "g");
- pressKey(win, "t");
- },
goToSettings: () => {
pressKey(win, "g");
pressKey(win, ",");
},
+ goToExplore: () => {
+ pressKey(win, "g");
+ pressKey(win, "e");
+ },
search: () => pressKey(win, "/"),
showShortcuts: () => pressKey(win, "/", ["shift"]),
};
From b27a959c2b4eaf888f73919ece812d8df385e06d Mon Sep 17 00:00:00 2001
From: Araxeus <78568641+Araxeus@users.noreply.github.com>
Date: Fri, 12 Nov 2021 18:42:58 +0200
Subject: [PATCH 07/10] fix video-toggle&precise-volume interaction
---
plugins/precise-volume/front.js | 4 ++--
plugins/video-toggle/front.js | 16 ++++++++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/plugins/precise-volume/front.js b/plugins/precise-volume/front.js
index 4bb606cd..189a20eb 100644
--- a/plugins/precise-volume/front.js
+++ b/plugins/precise-volume/front.js
@@ -39,13 +39,13 @@ function firstRun(options) {
function injectVolumeHud(noVid) {
if (noVid) {
const position = "top: 18px; right: 60px; z-index: 999; position: absolute;";
- const mainStyle = "font-size: xx-large; padding: 10px; transition: opacity 1s";
+ const mainStyle = "font-size: xx-large; padding: 10px; transition: opacity 1s; pointer-events: none;";
$(".center-content.ytmusic-nav-bar").insertAdjacentHTML("beforeend",
``)
} else {
const position = `top: 10px; left: 10px; z-index: 999; position: absolute;`;
- const mainStyle = "font-size: xxx-large; padding: 10px; transition: opacity 0.6s; webkit-text-stroke: 1px black; font-weight: 600;";
+ const mainStyle = "font-size: xxx-large; padding: 10px; transition: opacity 0.6s; webkit-text-stroke: 1px black; font-weight: 600; pointer-events: none;";
$("#song-video").insertAdjacentHTML('afterend',
``)
diff --git a/plugins/video-toggle/front.js b/plugins/video-toggle/front.js
index 1c3911e3..76ec8f5d 100644
--- a/plugins/video-toggle/front.js
+++ b/plugins/video-toggle/front.js
@@ -21,7 +21,7 @@ function setup(e) {
api = e.detail;
player = $('ytmusic-player');
video = $('video');
-
+
$('ytmusic-player-page').prepend(switchButtonDiv);
$('#song-image.ytmusic-player').style.display = "block";
@@ -48,7 +48,10 @@ function changeDisplay(showVideo) {
player.style.margin = showVideo ? '' : 'auto 0px';
player.setAttribute('playback-mode', showVideo ? 'OMV_PREFERRED' : 'ATV_PREFERRED');
$('#song-video.ytmusic-player').style.display = showVideo ? 'unset' : 'none';
- if(showVideo && !video.style.top) video.style.top = `${(player.clientHeight - video.clientHeight) / 2}px`;
+ if (showVideo && !video.style.top) {
+ video.style.top = `${(player.clientHeight - video.clientHeight) / 2}px`;
+ }
+ moveVolumeHud(showVideo);
}
function videoStarted() {
@@ -63,6 +66,8 @@ function videoStarted() {
// change display to video mode if video exist & video is hidden & option.hideVideo = false
if (!options.hideVideo && $('#song-video.ytmusic-player').style.display === "none") {
changeDisplay(true);
+ } else {
+ moveVolumeHud(!options.hideVideo);
}
} else {
// video doesn't exist -> switch to song mode
@@ -85,3 +90,10 @@ function forcePlaybackMode() {
});
playbackModeObserver.observe(player, { attributeFilter: ["playback-mode"] });
}
+
+// if precise volume plugin is enabled, move its hud to be on top of the video
+function moveVolumeHud(showVideo) {
+ const volumeHud = $('#volumeHud');
+ if (volumeHud)
+ volumeHud.style.top = showVideo ? `${(player.clientHeight - video.clientHeight) / 2}px` : 0;
+}
From abc1712cf7669f21f8faee40adc956a4d34c162e Mon Sep 17 00:00:00 2001
From: Araxeus <78568641+Araxeus@users.noreply.github.com>
Date: Mon, 22 Nov 2021 18:33:32 +0200
Subject: [PATCH 08/10] fix counter prompt
---
package.json | 2 +-
yarn.lock | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 2228a191..20e288c9 100644
--- a/package.json
+++ b/package.json
@@ -68,7 +68,7 @@
"@ffmpeg/ffmpeg": "^0.10.0",
"async-mutex": "^0.3.2",
"browser-id3-writer": "^4.4.0",
- "custom-electron-prompt": "^1.2.0",
+ "custom-electron-prompt": "^1.3.0",
"chokidar": "^3.5.2",
"custom-electron-titlebar": "^3.2.7",
"discord-rpc": "^3.2.0",
diff --git a/yarn.lock b/yarn.lock
index 7a9b8336..ec8e899c 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2903,10 +2903,10 @@ cssstyle@^2.3.0:
dependencies:
cssom "~0.3.6"
-custom-electron-prompt@^1.2.0:
- version "1.2.0"
- resolved "https://registry.yarnpkg.com/custom-electron-prompt/-/custom-electron-prompt-1.2.0.tgz#6bf5d00221291f9b886b8052e82d68e296383e68"
- integrity sha512-+AgL6JMzR91zaPdbZIMEOO2DVAHVGeZQbWpQl/v+XCAVzOaj26B6IwVg96VuYsCewGMuHK7mF3LbWWoLoOe/kQ==
+custom-electron-prompt@^1.3.0:
+ version "1.3.0"
+ resolved "https://registry.yarnpkg.com/custom-electron-prompt/-/custom-electron-prompt-1.3.0.tgz#33a46af79c6abceba5640a294e6138756fa44131"
+ integrity sha512-aflX6M9kyB5hsEY3bV7U6PAuCZfaHnI4v95WNTs3foJhlvERBFkqjcAYurIxJ2qnVHyGh/8hRlCtZzEJ4Av0iw==
custom-electron-titlebar@^3.2.7:
version "3.2.7"
From 7ba205cc6c35f1ac9b29350e83d56ce9ec64d08a Mon Sep 17 00:00:00 2001
From: Araxeus <78568641+Araxeus@users.noreply.github.com>
Date: Mon, 22 Nov 2021 18:59:29 +0200
Subject: [PATCH 09/10] fix backquotes in keybind prompt
---
package.json | 2 +-
yarn.lock | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 20e288c9..e09fd0cd 100644
--- a/package.json
+++ b/package.json
@@ -68,7 +68,7 @@
"@ffmpeg/ffmpeg": "^0.10.0",
"async-mutex": "^0.3.2",
"browser-id3-writer": "^4.4.0",
- "custom-electron-prompt": "^1.3.0",
+ "custom-electron-prompt": "^1.3.1",
"chokidar": "^3.5.2",
"custom-electron-titlebar": "^3.2.7",
"discord-rpc": "^3.2.0",
diff --git a/yarn.lock b/yarn.lock
index ec8e899c..c414d30b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2903,10 +2903,10 @@ cssstyle@^2.3.0:
dependencies:
cssom "~0.3.6"
-custom-electron-prompt@^1.3.0:
- version "1.3.0"
- resolved "https://registry.yarnpkg.com/custom-electron-prompt/-/custom-electron-prompt-1.3.0.tgz#33a46af79c6abceba5640a294e6138756fa44131"
- integrity sha512-aflX6M9kyB5hsEY3bV7U6PAuCZfaHnI4v95WNTs3foJhlvERBFkqjcAYurIxJ2qnVHyGh/8hRlCtZzEJ4Av0iw==
+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-titlebar@^3.2.7:
version "3.2.7"
From e917abaec953af3937903a7cda94089a1b273625 Mon Sep 17 00:00:00 2001
From: Araxeus <78568641+Araxeus@users.noreply.github.com>
Date: Wed, 1 Dec 2021 00:08:55 +0200
Subject: [PATCH 10/10] fix merge error
---
plugins/video-toggle/front.js | 3 ---
1 file changed, 3 deletions(-)
diff --git a/plugins/video-toggle/front.js b/plugins/video-toggle/front.js
index 1807774a..a4b75a96 100644
--- a/plugins/video-toggle/front.js
+++ b/plugins/video-toggle/front.js
@@ -6,13 +6,10 @@ function $(selector) { return document.querySelector(selector); }
let options, player, video, api;
-let api;
-
const switchButtonDiv = ElementFromFile(
templatePath(__dirname, "button_template.html")
);
-
module.exports = (_options) => {
if (_options.forceHide) return;
options = _options;