From 47729130c9b4b389567943d615593dc8ae4ff6ee Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Wed, 23 Feb 2022 17:15:10 +0200 Subject: [PATCH 1/8] fix custom titlebar in prompt options --- providers/prompt-options.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/providers/prompt-options.js b/providers/prompt-options.js index 101b4f99..a34d3b1c 100644 --- a/providers/prompt-options.js +++ b/providers/prompt-options.js @@ -1,17 +1,18 @@ const path = require("path"); const is = require("electron-is"); +const { isEnabled } = require("../config/plugins"); const iconPath = path.join(__dirname, "..", "assets", "youtube-music-tray.png"); const customTitlebarPath = path.join(__dirname, "prompt-custom-titlebar.js"); -const promptOptions = is.macOS() ? { - customStylesheet: "dark", - icon: iconPath -} : { +const promptOptions = !is.macOS() && isEnabled("in-app-menu") ? { customStylesheet: "dark", // The following are used for custom titlebar frame: false, customScript: customTitlebarPath, +} : { + customStylesheet: "dark", + icon: iconPath }; module.exports = () => promptOptions; From d5e4f3af4610ae2302d2a1ae12c2dc705f6d470e Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Mon, 14 Mar 2022 22:00:57 +0200 Subject: [PATCH 2/8] fix volumeHud position in miniplayer --- plugins/precise-volume/back.js | 8 +++++++- plugins/precise-volume/front.js | 12 +++++------- plugins/precise-volume/volume-hud.css | 11 +++++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 plugins/precise-volume/volume-hud.css diff --git a/plugins/precise-volume/back.js b/plugins/precise-volume/back.js index f891ce32..3d8b23ac 100644 --- a/plugins/precise-volume/back.js +++ b/plugins/precise-volume/back.js @@ -1,9 +1,15 @@ +const { injectCSS } = require("../utils"); +const path = require("path"); + /* This is used to determine if plugin is actually active (not if its only enabled in options) */ let enabled = false; -module.exports = () => enabled = true; +module.exports = (win) => { + enabled = true; + injectCSS(win.webContents, path.join(__dirname, "volume-hud.css")); +} module.exports.enabled = () => enabled; diff --git a/plugins/precise-volume/front.js b/plugins/precise-volume/front.js index 3b1e34f1..b9370eee 100644 --- a/plugins/precise-volume/front.js +++ b/plugins/precise-volume/front.js @@ -45,23 +45,21 @@ function firstRun(options) { // Change options from renderer to keep sync ipcRenderer.on("setOptions", (_event, newOptions = {}) => { - for (option in newOptions) { - options[option] = newOptions[option]; - } + Object.assign(options, newOptions) setMenuOptions("precise-volume", options); }); } function injectVolumeHud(noVid) { if (noVid) { - const position = "top: 18px; right: 60px; z-index: 999; position: absolute;"; - const mainStyle = "font-size: xx-large; padding: 10px; transition: opacity 1s; pointer-events: none;"; + const position = "top: 18px; right: 60px;"; + const mainStyle = "font-size: xx-large;"; $(".center-content.ytmusic-nav-bar").insertAdjacentHTML("beforeend", ``) } else { - const position = `top: 10px; left: 10px; z-index: 999; position: absolute;`; - const mainStyle = "font-size: xxx-large; padding: 10px; transition: opacity 0.6s; webkit-text-stroke: 1px black; font-weight: 600; pointer-events: none;"; + const position = `top: 10px; left: 10px;`; + const mainStyle = "font-size: xxx-large; webkit-text-stroke: 1px black; font-weight: 600;"; $("#song-video").insertAdjacentHTML('afterend', ``) diff --git a/plugins/precise-volume/volume-hud.css b/plugins/precise-volume/volume-hud.css new file mode 100644 index 00000000..618b94fc --- /dev/null +++ b/plugins/precise-volume/volume-hud.css @@ -0,0 +1,11 @@ +#volumeHud { + z-index: 999; + position: absolute; + transition: opacity 0.6s; + pointer-events: none; + padding: 10px; +} + +ytmusic-player[player-ui-state_="MINIPLAYER"] #volumeHud { + top: 0 !important; +} From 7f085796716e0e7a6ef5db1acb9a9a267d52b309 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Mon, 21 Mar 2022 18:17:22 +0200 Subject: [PATCH 3/8] add always-on-top option --- index.js | 4 ++++ menu.js | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/index.js b/index.js index 2fdfac58..0d576231 100644 --- a/index.js +++ b/index.js @@ -165,6 +165,10 @@ function createMainWindow() { win.maximize(); } + if(config.get("options.alwaysOnTop")){ + win.setAlwaysOnTop(true); + } + const urlToLoad = config.get("options.resumeOnStart") ? config.get("url") : config.defaultConfig.url; diff --git a/menu.js b/menu.js index dda0f086..ee9e8f86 100644 --- a/menu.js +++ b/menu.js @@ -100,6 +100,15 @@ const mainMenuTemplate = (win) => { } }, }, + { + label: "Always on top", + type: "checkbox", + checked: config.get("options.alwaysOnTop"), + click: (item) => { + config.setMenuOption("options.alwaysOnTop", item.checked); + win.setAlwaysOnTop(item.checked); + }, + }, ...(is.windows() || is.linux() ? [ { From f9cf12b7d37dc7e9e8abe85e32033c5b93a0b3c3 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Wed, 6 Apr 2022 18:26:05 +0300 Subject: [PATCH 4/8] [precise-volume] fix expand-volume-slider not updating its value --- plugins/precise-volume/front.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/precise-volume/front.js b/plugins/precise-volume/front.js index 3b1e34f1..0556a53d 100644 --- a/plugins/precise-volume/front.js +++ b/plugins/precise-volume/front.js @@ -189,8 +189,12 @@ function changeVolume(toIncrease, options) { function updateVolumeSlider(options) { // Slider value automatically rounds to multiples of 5 - $("#volume-slider").value = options.savedVolume > 0 && options.savedVolume < 5 ? - 5 : options.savedVolume; + for (const slider of ["#volume-slider", "#expand-volume-slider"]) { + $(slider).value = + options.savedVolume > 0 && options.savedVolume < 5 + ? 5 + : options.savedVolume; + } } let volumeHoverTimeoutID; From b6ee8611660e2d61bfda4d9f5f520cb9e7639aaf Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Wed, 6 Apr 2022 18:57:39 +0300 Subject: [PATCH 5/8] Fix lyrics genius missing parts --- plugins/lyrics-genius/front.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/plugins/lyrics-genius/front.js b/plugins/lyrics-genius/front.js index 4fcb3153..8632b85b 100644 --- a/plugins/lyrics-genius/front.js +++ b/plugins/lyrics-genius/front.js @@ -34,17 +34,12 @@ module.exports = () => { console.log("Fetched lyrics from Genius"); } - const wrapper = document.createElement("div"); + const wrapper = document.createElement("div") wrapper.innerHTML = html; - const lyricsSelector1 = wrapper.querySelector(".lyrics"); - const lyricsSelector2 = wrapper.querySelector( - '[class^="Lyrics__Container"]' - ); - const lyrics = lyricsSelector1 - ? lyricsSelector1.innerHTML - : lyricsSelector2 - ? lyricsSelector2.innerHTML - : null; + const lyricsSelector1 = Array.from(wrapper.querySelectorAll('[class^="Lyrics__Container"]')).map(d => d.innerHTML).join('
') + const lyricsSelector2 = wrapper.querySelector(".lyrics")?.innerHTML; + + const lyrics = lyricsSelector1 || lyricsSelector2 || null if (!lyrics) { return; } From 0d3fa261a7e09f05e90de0ac4d6d04aa7ea572c5 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Wed, 6 Apr 2022 19:48:58 +0300 Subject: [PATCH 6/8] feat: option to force show like buttons --- menu.js | 25 +++++++++++++++++++------ preload.js | 14 +++++++++++--- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/menu.js b/menu.js index dda0f086..2507e5be 100644 --- a/menu.js +++ b/menu.js @@ -80,12 +80,25 @@ const mainMenuTemplate = (win) => { }, }, { - label: "Remove upgrade button", - type: "checkbox", - checked: config.get("options.removeUpgradeButton"), - click: (item) => { - config.setMenuOption("options.removeUpgradeButton", item.checked); - }, + label: "Visual Tweaks", + submenu: [ + { + label: "Remove upgrade button", + type: "checkbox", + checked: config.get("options.removeUpgradeButton"), + click: (item) => { + config.setMenuOption("options.removeUpgradeButton", item.checked); + }, + }, + { + label: "Force show like buttons", + type: "checkbox", + checked: config.get("options.ForceShowLikeButtons"), + click: (item) => { + config.set("options.ForceShowLikeButtons", item.checked); + }, + }, + ], }, { label: "Single instance lock", diff --git a/preload.js b/preload.js index 621f46c0..618d50ae 100644 --- a/preload.js +++ b/preload.js @@ -83,9 +83,17 @@ function onApiLoaded() { // Remove upgrade button if (config.get("options.removeUpgradeButton")) { - const upgradeButtton = document.querySelector('ytmusic-pivot-bar-item-renderer[tab-id="SPunlimited"]') - if (upgradeButtton) { - upgradeButtton.style.display = "none"; + const upgradeButton = document.querySelector('ytmusic-pivot-bar-item-renderer[tab-id="SPunlimited"]') + if (upgradeButton) { + upgradeButton.style.display = "none"; + } + } + + // Force show like buttons + if (config.get("options.ForceShowLikeButtons")) { + const likeButtons = document.querySelector('ytmusic-like-button-renderer') + if (likeButtons) { + likeButtons.style.display = 'inherit'; } } } From c31f6cc79718ff80bf7c0823c988edc3199383ec Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Wed, 6 Apr 2022 18:57:39 +0300 Subject: [PATCH 7/8] Fix lyrics genius missing parts --- plugins/lyrics-genius/front.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/plugins/lyrics-genius/front.js b/plugins/lyrics-genius/front.js index 4fcb3153..917132f0 100644 --- a/plugins/lyrics-genius/front.js +++ b/plugins/lyrics-genius/front.js @@ -36,15 +36,10 @@ module.exports = () => { const wrapper = document.createElement("div"); wrapper.innerHTML = html; - const lyricsSelector1 = wrapper.querySelector(".lyrics"); - const lyricsSelector2 = wrapper.querySelector( - '[class^="Lyrics__Container"]' - ); - const lyrics = lyricsSelector1 - ? lyricsSelector1.innerHTML - : lyricsSelector2 - ? lyricsSelector2.innerHTML - : null; + + const lyrics = Array.from(wrapper.querySelectorAll('[class^="Lyrics__Container"]')).map(d => d.innerHTML).join('
') + || wrapper.querySelector(".lyrics")?.innerHTML; + if (!lyrics) { return; } From d47b03c23debfc561a49f1dc34dbe1572c3f106e Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Wed, 6 Apr 2022 20:15:24 +0300 Subject: [PATCH 8/8] use spread syntax instead of Array.from --- plugins/lyrics-genius/front.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/lyrics-genius/front.js b/plugins/lyrics-genius/front.js index b62ad89e..d000a13c 100644 --- a/plugins/lyrics-genius/front.js +++ b/plugins/lyrics-genius/front.js @@ -37,7 +37,7 @@ module.exports = () => { const wrapper = document.createElement("div"); wrapper.innerHTML = html; - const lyrics = Array.from(wrapper.querySelectorAll('[class^="Lyrics__Container"]')).map(d => d.innerHTML).join('
') + const lyrics = [...wrapper.querySelectorAll('[class^="Lyrics__Container"]')].map(d => d.innerHTML).join('
') || wrapper.querySelector(".lyrics")?.innerHTML; if (!lyrics) {