From 36864b4c2f87de3fa6db883ecca01bc947ccf95c Mon Sep 17 00:00:00 2001 From: TC Date: Wed, 31 Mar 2021 20:17:12 +0200 Subject: [PATCH] Format custom menu plugin --- plugins/styled-bars/back.js | 34 +++++++++++++------------- plugins/styled-bars/front.js | 16 ++++++------ plugins/styled-bars/style.css | 46 ++++++++++++++++++----------------- 3 files changed, 49 insertions(+), 47 deletions(-) diff --git a/plugins/styled-bars/back.js b/plugins/styled-bars/back.js index 37fd6c8b..cd8afbf2 100644 --- a/plugins/styled-bars/back.js +++ b/plugins/styled-bars/back.js @@ -1,8 +1,8 @@ -const { injectCSS } = require('../utils'); -const { Menu } = require('electron'); -const path = require('path'); +const { injectCSS } = require("../utils"); +const { Menu } = require("electron"); +const path = require("path"); const electronLocalshortcut = require("electron-localshortcut"); -const config = require('../../config'); +const config = require("../../config"); var { mainMenuTemplate } = require("../../menu"); //override menu template for custom menu @@ -14,31 +14,31 @@ mainMenuTemplate = function (winHook) { fixMenu(template); //return as normal return template; -} +}; //win hook for fixing menu let win; //check that menu doesn't get created twice let done = false; -module.exports = winImport => { +module.exports = (winImport) => { win = 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) + injectCSS(win.webContents, path.join(__dirname, "style.css")); + win.on("ready-to-show", () => { + // (apparently ready-to-show is called twice) if (done) { - return + return; } done = true; let template = mainMenuTemplate(win); let menu = Menu.buildFromTemplate(template); Menu.setApplicationMenu(menu); - + //register keyboard shortcut && hide menu if hideMenu is enabled - if (config.get('options.hideMenu')) { + if (config.get("options.hideMenu")) { switchMenuVisibility(); - electronLocalshortcut.register(win, 'Esc', () => { + electronLocalshortcut.register(win, "Esc", () => { switchMenuVisibility(); }); } @@ -47,8 +47,8 @@ module.exports = winImport => { let visible = true; function switchMenuVisibility() { - visible=!visible; - win.webContents.send('updateMenu',visible) + visible = !visible; + win.webContents.send("updateMenu", visible); } //go over each item in menu @@ -60,7 +60,7 @@ function fixMenu(template) { fixMenu(item.submenu); } //change onClick of checkbox+radio - else if (item.type === 'checkbox' || item.type === 'radio') { + else if (item.type === "checkbox" || item.type === "radio") { let ogOnclick = item.click; item.click = (itemClicked) => { ogOnclick(itemClicked); @@ -107,5 +107,5 @@ function checkCheckbox(item) { //check item item.checked = !item.checked; //update menu (closes it) - win.webContents.send('updateMenu', true); + win.webContents.send("updateMenu", true); } diff --git a/plugins/styled-bars/front.js b/plugins/styled-bars/front.js index d5274364..ad0fb064 100644 --- a/plugins/styled-bars/front.js +++ b/plugins/styled-bars/front.js @@ -1,15 +1,15 @@ -const customTitlebar = require('custom-electron-titlebar'); -const {remote, ipcRenderer} = require('electron'); +const customTitlebar = require("custom-electron-titlebar"); +const { remote, ipcRenderer } = require("electron"); module.exports = () => { const myBar = new customTitlebar.Titlebar({ - backgroundColor: customTitlebar.Color.fromHex('#050505'), - itemBackgroundColor: customTitlebar.Color.fromHex('#121212') + backgroundColor: customTitlebar.Color.fromHex("#050505"), + itemBackgroundColor: customTitlebar.Color.fromHex("#121212"), }); - myBar.updateTitle(' '); - document.title = 'Youtube Music'; + myBar.updateTitle(" "); + document.title = "Youtube Music"; - ipcRenderer.on('updateMenu', function (event, menu) { + ipcRenderer.on("updateMenu", function (event, menu) { if (menu) { myBar.updateMenu(remote.Menu.getApplicationMenu()); } else { @@ -20,4 +20,4 @@ module.exports = () => { } } }); -}; \ No newline at end of file +}; diff --git a/plugins/styled-bars/style.css b/plugins/styled-bars/style.css index f0d0c88b..641b94cd 100644 --- a/plugins/styled-bars/style.css +++ b/plugins/styled-bars/style.css @@ -1,21 +1,22 @@ /* increase font size for menu and menuItems */ -.titlebar, .menubar-menu-container .action-label{ - font-size: 14px !important; +.titlebar, +.menubar-menu-container .action-label { + font-size: 14px !important; } /* allow submenu's to show correctly */ -.menubar-menu-container{ - overflow-y: visible !important; +.menubar-menu-container { + overflow-y: visible !important; } /* fixes scrollbar positioning relative to nav bar */ #nav-bar-background.ytmusic-app-layout { - right: 15px !important; + right: 15px !important; } /* remove window dragging for nav bar (conflict with titlebar drag) */ -ytmusic-nav-bar, +ytmusic-nav-bar, .tab-titleiron-icon, ytmusic-pivot-bar-item-renderer { - -webkit-app-region : unset; + -webkit-app-region: unset; } /* Move navBar downwards and make it opaque */ @@ -28,34 +29,35 @@ ytmusic-search-box.ytmusic-nav-bar { } .center-content.ytmusic-nav-bar { - background: #030303; + background: #030303; } -yt-page-navigation-progress, +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-item-section-renderer[has-item-section-tabbed-header-renderer_] + #header.ytmusic-item-section-renderer, ytmusic-header-renderer.ytmusic-search-page { - top: 90px !important; + top: 90px !important; } /* Custom scrollbar */ ::-webkit-scrollbar { - width: 12px; - background-color: #030303; - -webkit-border-radius: 100px; + width: 12px; + background-color: #030303; + -webkit-border-radius: 100px; } /* hover effect for both scrollbar area, and scrollbar 'thumb' */ ::-webkit-scrollbar:hover { - background-color: rgba(15, 15, 15, 0.699); + background-color: rgba(15, 15, 15, 0.699); } /* The scrollbar 'thumb' ...that marque oval shape in a scrollbar */ ::-webkit-scrollbar-thumb:vertical { - background-clip: padding-box; - border: 2px solid rgba(0, 0, 0, 0); + background-clip: padding-box; + border: 2px solid rgba(0, 0, 0, 0); - background: rgb(49, 0, 0); - -webkit-border-radius: 100px; + background: rgb(49, 0, 0); + -webkit-border-radius: 100px; } ::-webkit-scrollbar-thumb:vertical:active { - background: rgb(56, 0, 0); /* Some darker color when you click it */ - -webkit-border-radius: 100px; -} \ No newline at end of file + background: rgb(56, 0, 0); /* Some darker color when you click it */ + -webkit-border-radius: 100px; +}