show volume hud in videoplayer if available

This commit is contained in:
Araxeus
2021-05-13 03:18:24 +03:00
parent 71ba6b8e55
commit ea672c2423

View File

@ -17,9 +17,9 @@ module.exports = (options) => {
} }
ipcRenderer.on("did-finish-load", () => { ipcRenderer.on("did-finish-load", () => {
injectVolumeHud(); const noVid = $("#main-panel")?.computedStyleMap().get("display").value === "none";
// if hideVideo is disabled injectVolumeHud(noVid);
if ($("#main-panel")?.computedStyleMap().get("display").value !== "none") { if (!noVid) {
setupVideoPlayerOnwheel(options); setupVideoPlayerOnwheel(options);
} }
}); });
@ -27,11 +27,20 @@ module.exports = (options) => {
firstRun(options); firstRun(options);
}; };
function injectVolumeHud() { function injectVolumeHud(noVid) {
const position = "top: 18px; right: 60px; z-index: 999; position: absolute;"; if (noVid) {
const mainStyle = "font-size: xx-large; padding: 10px; transition: opacity 1.5s"; const position = "top: 18px; right: 60px; z-index: 999; position: absolute;";
$(".center-content.ytmusic-nav-bar").insertAdjacentHTML("beforeend", const mainStyle = "font-size: xx-large; padding: 10px; transition: opacity 1s";
`<span id="volumeHud" style="${position + mainStyle}"></span>`)
$(".center-content.ytmusic-nav-bar").insertAdjacentHTML("beforeend",
`<span id="volumeHud" style="${position + mainStyle}"></span>`)
} 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;";
$("#song-video").insertAdjacentHTML('afterend',
`<span id="volumeHud" style="${position + mainStyle}"></span>`)
}
} }
let hudFadeTimeout; let hudFadeTimeout;