Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PiP] Remove titlebar when in-app-menu is enabled #1024

Merged
merged 1 commit into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions plugins/picture-in-picture/adaptors/in-app-menu.js

This file was deleted.

13 changes: 1 addition & 12 deletions plugins/picture-in-picture/back.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require("path");
const { app, ipcMain } = require("electron");
const electronLocalshortcut = require("electron-localshortcut");

const { setOptions, isEnabled } = require("../../config/plugins");
const { setOptions } = require("../../config/plugins");
const { injectCSS } = require("../utils");

let isInPiP = false;
Expand All @@ -23,15 +23,6 @@ const setLocalOptions = (_options) => {
setOptions("picture-in-picture", _options);
}


const adaptors = [];
const runAdaptors = () => adaptors.forEach(a => a());

if (isEnabled("in-app-menu")) {
let adaptor = require("./adaptors/in-app-menu");
adaptors.push(() => adaptor(win, options, setLocalOptions, togglePiP, isInPiP));
}

const togglePiP = async () => {
isInPiP = !isInPiP;
setLocalOptions({ isInPiP });
Expand All @@ -50,7 +41,6 @@ const togglePiP = async () => {
win.setMaximizable(false);
win.setFullScreenable(false);

runAdaptors();
win.webContents.send("pip-toggle", true);

app.dock?.hide();
Expand All @@ -66,7 +56,6 @@ const togglePiP = async () => {
win.setMaximizable(true);
win.setFullScreenable(true);

runAdaptors();
win.webContents.send("pip-toggle", false);

win.setVisibleOnAllWorkspaces(false);
Expand Down
6 changes: 5 additions & 1 deletion plugins/picture-in-picture/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const listenForToggle = () => {
const player = $('#player');
const onPlayerDblClick = player.onDoubleClick_;

const titlebar = $('.cet-titlebar');

ipcRenderer.on('pip-toggle', (_, isPip) => {
if (isPip) {
replaceButton(".exit-fullscreen-button", originalExitButton).onclick = () => togglePictureInPicture();
Expand All @@ -64,12 +66,14 @@ const listenForToggle = () => {
}
fullScreenButton.click();
appLayout.classList.add("pip");
if (titlebar) titlebar.style.display = 'none';
} else {
$(".exit-fullscreen-button").replaceWith(originalExitButton);
player.onDoubleClick_ = onPlayerDblClick;
expandMenu.onmouseleave = undefined;
originalExitButton.click();
appLayout.classList.remove("pip");
if (titlebar) titlebar.style.display = 'flex';
}
});
}
Expand All @@ -80,7 +84,7 @@ function observeMenu(options) {
() => {
listenForToggle();
// remove native listeners
cloneButton(".player-minimize-button").onclick = () => {
cloneButton(".player-minimize-button").onclick = () => {
global.togglePictureInPicture();
setTimeout(() => $('#player').click());
};
Expand Down
23 changes: 20 additions & 3 deletions plugins/picture-in-picture/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ ytmusic-app-layout.pip ytmusic-player-bar svg,
ytmusic-app-layout.pip ytmusic-player-bar .time-info,
ytmusic-app-layout.pip ytmusic-player-bar yt-formatted-string,
ytmusic-app-layout.pip ytmusic-player-bar .yt-formatted-string {
filter: drop-shadow(2px 4px 6px black);
color: white !important;
fill: white !important;
filter: drop-shadow(2px 4px 6px black);
color: white !important;
fill: white !important;
}

/* improve the style of the player bar expanding menu */
Expand All @@ -20,6 +20,23 @@ ytmusic-app-layout.pip ytmusic-player-expanding-menu {
top: 22px !important;
}

/* make player-bar not draggable if in-app-menu is enabled */
.cet-container ytmusic-app-layout.pip ytmusic-player-bar {
-webkit-app-region: no-drag !important;
}

/* make player draggable if in-app-menu is enabled */
.cet-container ytmusic-app-layout.pip #player {
-webkit-app-region: drag !important;
}

/* remove info, thumbnail and menu from player-bar */
ytmusic-app-layout.pip ytmusic-player-bar .content-info-wrapper,
ytmusic-app-layout.pip ytmusic-player-bar .thumbnail-image-wrapper,
ytmusic-app-layout.pip ytmusic-player-bar ytmusic-menu-renderer {
display: none !important;
}

/* disable the video-toggle button when in PiP mode */
ytmusic-app-layout.pip .video-switch-button {
display: none !important;
Expand Down
5 changes: 5 additions & 0 deletions youtube-music.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ img {
ytmusic-cast-button {
display: none !important;
}

/* Remove useless inaccessible button on top-right corner of the video player */
.ytp-chrome-top-buttons {
display: none !important;
}