mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
const { ipcRenderer } = require("electron");
|
|
const config = require("../../config");
|
|
const { Titlebar, Color } = require("custom-electron-titlebar");
|
|
function $(selector) { return document.querySelector(selector); }
|
|
|
|
module.exports = () => {
|
|
let visible = !config.get("options.hideMenu");
|
|
const bar = new Titlebar({
|
|
backgroundColor: Color.fromHex("#050505"),
|
|
itemBackgroundColor: Color.fromHex("#121212"),
|
|
svgColor: Color.WHITE,
|
|
menu: visible ? undefined : null
|
|
});
|
|
bar.updateTitle(" ");
|
|
document.title = "Youtube Music";
|
|
|
|
ipcRenderer.on("refreshMenu", (_, showMenu) => {
|
|
if (showMenu === undefined && !visible) return;
|
|
if (showMenu === false) {
|
|
bar.updateMenu(null);
|
|
visible = false;
|
|
} else {
|
|
bar.refreshMenu();
|
|
visible = true;
|
|
}
|
|
});
|
|
|
|
// Increases the right margin of Navbar background when the scrollbar is visible to avoid blocking it (z-index doesn't affect it)
|
|
document.addEventListener('apiLoaded', () => {
|
|
setNavbarMargin();
|
|
const playPageObserver = new MutationObserver(setNavbarMargin);
|
|
playPageObserver.observe($('ytmusic-app-layout'), { attributeFilter: ['player-page-open_', 'playerPageOpen_'] })
|
|
}, { once: true, passive: true })
|
|
};
|
|
|
|
function setNavbarMargin() {
|
|
$('#nav-bar-background').style.right =
|
|
$('ytmusic-app-layout').playerPageOpen_ ?
|
|
'0px' :
|
|
'12px';
|
|
}
|