mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix PiP unminimize button hidden
This commit is contained in:
@ -10,6 +10,21 @@ const pipButton = ElementFromFile(
|
|||||||
templatePath(__dirname, "picture-in-picture.html")
|
templatePath(__dirname, "picture-in-picture.html")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// will also clone
|
||||||
|
function replaceButton(query, button) {
|
||||||
|
const svg = button.querySelector("#icon svg").cloneNode(true);
|
||||||
|
button.replaceWith(button.cloneNode(true));
|
||||||
|
button.remove();
|
||||||
|
const newButton = $(query);
|
||||||
|
newButton.querySelector("#icon").appendChild(svg);
|
||||||
|
return newButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
function cloneButton(query) {
|
||||||
|
replaceButton(query, $(query));
|
||||||
|
return $(query);
|
||||||
|
}
|
||||||
|
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(() => {
|
||||||
if (!menu) {
|
if (!menu) {
|
||||||
menu = getSongMenu();
|
menu = getSongMenu();
|
||||||
@ -30,9 +45,6 @@ global.togglePictureInPicture = () => {
|
|||||||
|
|
||||||
const listenForToggle = () => {
|
const listenForToggle = () => {
|
||||||
const originalExitButton = $(".exit-fullscreen-button");
|
const originalExitButton = $(".exit-fullscreen-button");
|
||||||
const clonedExitButton = originalExitButton.cloneNode(true);
|
|
||||||
clonedExitButton.onclick = () => togglePictureInPicture();
|
|
||||||
|
|
||||||
const appLayout = $("ytmusic-app-layout");
|
const appLayout = $("ytmusic-app-layout");
|
||||||
const expandMenu = $('#expanding-menu');
|
const expandMenu = $('#expanding-menu');
|
||||||
const middleControls = $('.middle-controls');
|
const middleControls = $('.middle-controls');
|
||||||
@ -44,7 +56,7 @@ const listenForToggle = () => {
|
|||||||
|
|
||||||
ipcRenderer.on('pip-toggle', (_, isPip) => {
|
ipcRenderer.on('pip-toggle', (_, isPip) => {
|
||||||
if (isPip) {
|
if (isPip) {
|
||||||
$(".exit-fullscreen-button").replaceWith(clonedExitButton);
|
replaceButton(".exit-fullscreen-button", originalExitButton).onclick = () => togglePictureInPicture();
|
||||||
player.onDoubleClick_ = () => {};
|
player.onDoubleClick_ = () => {};
|
||||||
expandMenu.onmouseleave = () => middleControls.click();
|
expandMenu.onmouseleave = () => middleControls.click();
|
||||||
if (!playerPage.playerPageOpen_) {
|
if (!playerPage.playerPageOpen_) {
|
||||||
@ -67,12 +79,8 @@ function observeMenu(options) {
|
|||||||
"apiLoaded",
|
"apiLoaded",
|
||||||
() => {
|
() => {
|
||||||
listenForToggle();
|
listenForToggle();
|
||||||
const minButton = $(".player-minimize-button");
|
|
||||||
// remove native listeners
|
// remove native listeners
|
||||||
const svg = $(".player-minimize-button #icon svg").cloneNode(true);
|
cloneButton(".player-minimize-button").onclick = () => {
|
||||||
minButton.replaceWith(minButton.cloneNode(true));
|
|
||||||
$(".player-minimize-button #icon").appendChild(svg);
|
|
||||||
$(".player-minimize-button").onclick = () => {
|
|
||||||
global.togglePictureInPicture();
|
global.togglePictureInPicture();
|
||||||
setTimeout(() => $('#player').click());
|
setTimeout(() => $('#player').click());
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user