mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 03:11:46 +00:00
Merge remote-tracking branch 'upstream/master' into custom-electron-prompt
This commit is contained in:
@ -7,8 +7,8 @@ const config = require("../../config");
|
||||
const { setApplicationMenu } = require("../../menu");
|
||||
const { injectCSS } = require("../utils");
|
||||
|
||||
//check that menu doesn't get created twice
|
||||
let done = false;
|
||||
//tracks menu visibility
|
||||
let visible = true;
|
||||
// win hook for fixing menu
|
||||
let win;
|
||||
|
||||
@ -16,7 +16,7 @@ const originalBuildMenu = Menu.buildFromTemplate;
|
||||
// This function natively gets called on all submenu so no more reason to use recursion
|
||||
Menu.buildFromTemplate = (template) => {
|
||||
// Fix checkboxes and radio buttons
|
||||
updateCheckboxesAndRadioButtons(win, template);
|
||||
updateTemplate(template);
|
||||
|
||||
// return as normal
|
||||
return originalBuildMenu(template);
|
||||
@ -28,47 +28,54 @@ module.exports = (winImport) => {
|
||||
// css for custom scrollbar + disable drag area(was causing bugs)
|
||||
injectCSS(win.webContents, path.join(__dirname, "style.css"));
|
||||
|
||||
win.on("ready-to-show", () => {
|
||||
// (apparently ready-to-show is called twice)
|
||||
if (done) {
|
||||
return;
|
||||
}
|
||||
done = true;
|
||||
win.once("ready-to-show", () => {
|
||||
|
||||
setApplicationMenu(win);
|
||||
|
||||
//register keyboard shortcut && hide menu if hideMenu is enabled
|
||||
if (config.get("options.hideMenu")) {
|
||||
switchMenuVisibility(win);
|
||||
electronLocalshortcut.register(win, "Esc", () => {
|
||||
switchMenuVisibility(win);
|
||||
switchMenuVisibility();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//set menu visibility on load
|
||||
win.webContents.once("did-finish-load", () => {
|
||||
// fix bug with menu not applying on start when no internet connection available
|
||||
setMenuVisibility(!config.get("options.hideMenu"));
|
||||
});
|
||||
};
|
||||
|
||||
let visible = true;
|
||||
function switchMenuVisibility(win) {
|
||||
visible = !visible;
|
||||
function switchMenuVisibility() {
|
||||
setMenuVisibility(!visible);
|
||||
}
|
||||
|
||||
function setMenuVisibility(value) {
|
||||
visible = value;
|
||||
win.webContents.send("updateMenu", visible);
|
||||
}
|
||||
|
||||
function checkCheckbox(win, item) {
|
||||
//check item
|
||||
item.checked = !item.checked;
|
||||
//update menu (closes it)
|
||||
win.webContents.send("updateMenu", true);
|
||||
function updateCheckboxesAndRadioButtons(item, isRadio, hasSubmenu) {
|
||||
if (!isRadio) {
|
||||
//fix checkbox
|
||||
item.checked = !item.checked;
|
||||
}
|
||||
//update menu if radio / hasSubmenu
|
||||
if (isRadio || hasSubmenu) {
|
||||
win.webContents.send("updateMenu", true);
|
||||
}
|
||||
}
|
||||
|
||||
// Update checkboxes/radio buttons
|
||||
function updateCheckboxesAndRadioButtons(win, template) {
|
||||
function updateTemplate(template) {
|
||||
for (let item of template) {
|
||||
// Change onClick of checkbox+radio
|
||||
if ((item.type === "checkbox" || item.type === "radio") && !item.fixed) {
|
||||
let originalOnclick = item.click;
|
||||
const originalOnclick = item.click;
|
||||
item.click = (itemClicked) => {
|
||||
originalOnclick(itemClicked);
|
||||
checkCheckbox(win, itemClicked);
|
||||
updateCheckboxesAndRadioButtons(itemClicked, item.type === "radio", item.hasSubmenu);
|
||||
};
|
||||
item.fixed = true;
|
||||
}
|
||||
|
||||
@ -8,36 +8,46 @@
|
||||
.menubar-menu-container {
|
||||
overflow-y: visible !important;
|
||||
}
|
||||
|
||||
/* fixes scrollbar positioning relative to nav bar */
|
||||
#nav-bar-background.ytmusic-app-layout {
|
||||
right: 15px !important;
|
||||
}
|
||||
|
||||
/* remove window dragging for nav bar (conflict with titlebar drag) */
|
||||
ytmusic-nav-bar,
|
||||
.tab-titleiron-icon,
|
||||
ytmusic-pivot-bar-item-renderer {
|
||||
-webkit-app-region: unset;
|
||||
}
|
||||
|
||||
/* Move navBar downwards and make it opaque */
|
||||
ytmusic-app-layout {
|
||||
--ytmusic-nav-bar-height: 120px;
|
||||
}
|
||||
|
||||
ytmusic-search-box.ytmusic-nav-bar {
|
||||
margin-top: 29px;
|
||||
-webkit-app-region: unset !important;
|
||||
}
|
||||
|
||||
/* navbar background black */
|
||||
.center-content.ytmusic-nav-bar {
|
||||
background: #030303;
|
||||
}
|
||||
yt-page-navigation-progress,
|
||||
#progress.yt-page-navigation-progress,
|
||||
ytmusic-item-section-renderer[has-item-section-tabbed-header-renderer_]
|
||||
#header.ytmusic-item-section-renderer,
|
||||
ytmusic-header-renderer.ytmusic-search-page {
|
||||
top: 90px !important;
|
||||
|
||||
/* move up item selectrion renderer by 15 px */
|
||||
ytmusic-item-section-renderer[has-item-section-tabbed-header-renderer_] #header.ytmusic-item-section-renderer {
|
||||
top: 75 !important;
|
||||
}
|
||||
|
||||
/* fix weird positioning in search screen*/
|
||||
ytmusic-header-renderer.ytmusic-search-page {
|
||||
position: unset !important;
|
||||
}
|
||||
|
||||
/* Move navBar downwards */
|
||||
ytmusic-app-layout > [slot="nav-bar"],
|
||||
#nav-bar-background.ytmusic-app-layout {
|
||||
top: 17px !important;
|
||||
}
|
||||
|
||||
/* fix page progress bar position*/
|
||||
yt-page-navigation-progress,
|
||||
#progress.yt-page-navigation-progress {
|
||||
top: 30px !important;
|
||||
}
|
||||
|
||||
/* Custom scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 12px;
|
||||
@ -56,13 +66,13 @@ ytmusic-header-renderer.ytmusic-search-page {
|
||||
background-clip: padding-box;
|
||||
border: 2px solid rgba(0, 0, 0, 0);
|
||||
|
||||
background: rgb(49, 0, 0);
|
||||
background: #3a3a3a;
|
||||
border-radius: 100px;
|
||||
-moz-border-radius: 100px;
|
||||
-webkit-border-radius: 100px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:vertical:active {
|
||||
background: rgb(56, 0, 0); /* Some darker color when you click it */
|
||||
background: #4d4c4c; /* Some darker color when you click it */
|
||||
border-radius: 100px;
|
||||
-moz-border-radius: 100px;
|
||||
-webkit-border-radius: 100px;
|
||||
|
||||
Reference in New Issue
Block a user