mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 18:21:47 +00:00
Merge branch 'local-upstream/master' into migrate-from-remote-to-ipc
This commit is contained in:
4
index.js
4
index.js
@ -162,6 +162,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;
|
||||
|
||||
34
menu.js
34
menu.js
@ -81,12 +81,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",
|
||||
@ -101,6 +114,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()
|
||||
? [
|
||||
{
|
||||
|
||||
@ -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 = [...wrapper.querySelectorAll('[class^="Lyrics__Container"]')].map(d => d.innerHTML).join('<br>')
|
||||
|| wrapper.querySelector(".lyrics")?.innerHTML;
|
||||
|
||||
if (!lyrics) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
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)
|
||||
@ -8,6 +11,7 @@ const { globalShortcut } = require('electron');
|
||||
|
||||
module.exports = (win, options) => {
|
||||
enabled = true;
|
||||
injectCSS(win.webContents, path.join(__dirname, "volume-hud.css"));
|
||||
|
||||
if (options.globalShortcuts?.volumeUp) {
|
||||
globalShortcut.register((options.globalShortcuts.volumeUp), () => win.webContents.send('changeVolume', true));
|
||||
|
||||
@ -45,23 +45,21 @@ function firstRun() {
|
||||
|
||||
// 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",
|
||||
`<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; 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',
|
||||
`<span id="volumeHud" style="${position + mainStyle}"></span>`)
|
||||
@ -189,8 +187,12 @@ function changeVolume(toIncrease) {
|
||||
|
||||
function updateVolumeSlider() {
|
||||
// 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;
|
||||
|
||||
11
plugins/precise-volume/volume-hud.css
Normal file
11
plugins/precise-volume/volume-hud.css
Normal 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;
|
||||
}
|
||||
14
preload.js
14
preload.js
@ -77,9 +77,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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user