Merge pull request #645 from Araxeus/fix-volumeHud-position-on-miniplayer

[Precise-Volume] fix volumeHud position in miniplayer
This commit is contained in:
th-ch
2022-04-07 21:02:22 +02:00
committed by GitHub
3 changed files with 23 additions and 8 deletions

View File

@ -1,9 +1,15 @@
const { injectCSS } = require("../utils");
const path = require("path");
/* /*
This is used to determine if plugin is actually active This is used to determine if plugin is actually active
(not if its only enabled in options) (not if its only enabled in options)
*/ */
let enabled = false; 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; module.exports.enabled = () => enabled;

View File

@ -45,23 +45,21 @@ function firstRun(options) {
// Change options from renderer to keep sync // Change options from renderer to keep sync
ipcRenderer.on("setOptions", (_event, newOptions = {}) => { ipcRenderer.on("setOptions", (_event, newOptions = {}) => {
for (option in newOptions) { Object.assign(options, newOptions)
options[option] = newOptions[option];
}
setMenuOptions("precise-volume", options); setMenuOptions("precise-volume", options);
}); });
} }
function injectVolumeHud(noVid) { function injectVolumeHud(noVid) {
if (noVid) { if (noVid) {
const position = "top: 18px; right: 60px; z-index: 999; position: absolute;"; const position = "top: 18px; right: 60px;";
const mainStyle = "font-size: xx-large; padding: 10px; transition: opacity 1s; pointer-events: none;"; const mainStyle = "font-size: xx-large;";
$(".center-content.ytmusic-nav-bar").insertAdjacentHTML("beforeend", $(".center-content.ytmusic-nav-bar").insertAdjacentHTML("beforeend",
`<span id="volumeHud" style="${position + mainStyle}"></span>`) `<span id="volumeHud" style="${position + mainStyle}"></span>`)
} else { } else {
const position = `top: 10px; left: 10px; z-index: 999; position: absolute;`; const position = `top: 10px; left: 10px;`;
const mainStyle = "font-size: xxx-large; padding: 10px; transition: opacity 0.6s; webkit-text-stroke: 1px black; font-weight: 600; pointer-events: none;"; const mainStyle = "font-size: xxx-large; webkit-text-stroke: 1px black; font-weight: 600;";
$("#song-video").insertAdjacentHTML('afterend', $("#song-video").insertAdjacentHTML('afterend',
`<span id="volumeHud" style="${position + mainStyle}"></span>`) `<span id="volumeHud" style="${position + mainStyle}"></span>`)

View File

@ -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;
}