Merge branch 'local-upstream/master' into migrate-from-remote-to-ipc

This commit is contained in:
Araxeus
2022-04-07 22:12:25 +03:00
8 changed files with 78 additions and 31 deletions

View File

@ -162,6 +162,10 @@ function createMainWindow() {
win.maximize(); win.maximize();
} }
if(config.get("options.alwaysOnTop")){
win.setAlwaysOnTop(true);
}
const urlToLoad = config.get("options.resumeOnStart") const urlToLoad = config.get("options.resumeOnStart")
? config.get("url") ? config.get("url")
: config.defaultConfig.url; : config.defaultConfig.url;

22
menu.js
View File

@ -80,6 +80,9 @@ const mainMenuTemplate = (win) => {
config.setMenuOption("options.resumeOnStart", item.checked); config.setMenuOption("options.resumeOnStart", item.checked);
}, },
}, },
{
label: "Visual Tweaks",
submenu: [
{ {
label: "Remove upgrade button", label: "Remove upgrade button",
type: "checkbox", type: "checkbox",
@ -88,6 +91,16 @@ const mainMenuTemplate = (win) => {
config.setMenuOption("options.removeUpgradeButton", item.checked); 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", label: "Single instance lock",
type: "checkbox", type: "checkbox",
@ -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() ...(is.windows() || is.linux()
? [ ? [
{ {

View File

@ -36,15 +36,10 @@ module.exports = () => {
const wrapper = document.createElement("div"); const wrapper = document.createElement("div");
wrapper.innerHTML = html; wrapper.innerHTML = html;
const lyricsSelector1 = wrapper.querySelector(".lyrics");
const lyricsSelector2 = wrapper.querySelector( const lyrics = [...wrapper.querySelectorAll('[class^="Lyrics__Container"]')].map(d => d.innerHTML).join('<br>')
'[class^="Lyrics__Container"]' || wrapper.querySelector(".lyrics")?.innerHTML;
);
const lyrics = lyricsSelector1
? lyricsSelector1.innerHTML
: lyricsSelector2
? lyricsSelector2.innerHTML
: null;
if (!lyrics) { if (!lyrics) {
return; return;
} }

View File

@ -1,3 +1,6 @@
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)
@ -8,6 +11,7 @@ const { globalShortcut } = require('electron');
module.exports = (win, options) => { module.exports = (win, options) => {
enabled = true; enabled = true;
injectCSS(win.webContents, path.join(__dirname, "volume-hud.css"));
if (options.globalShortcuts?.volumeUp) { if (options.globalShortcuts?.volumeUp) {
globalShortcut.register((options.globalShortcuts.volumeUp), () => win.webContents.send('changeVolume', true)); globalShortcut.register((options.globalShortcuts.volumeUp), () => win.webContents.send('changeVolume', true));

View File

@ -45,23 +45,21 @@ function firstRun() {
// 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>`)
@ -189,8 +187,12 @@ function changeVolume(toIncrease) {
function updateVolumeSlider() { function updateVolumeSlider() {
// Slider value automatically rounds to multiples of 5 // Slider value automatically rounds to multiples of 5
$("#volume-slider").value = options.savedVolume > 0 && options.savedVolume < 5 ? for (const slider of ["#volume-slider", "#expand-volume-slider"]) {
5 : options.savedVolume; $(slider).value =
options.savedVolume > 0 && options.savedVolume < 5
? 5
: options.savedVolume;
}
} }
let volumeHoverTimeoutID; let volumeHoverTimeoutID;

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

View File

@ -77,9 +77,17 @@ function onApiLoaded() {
// Remove upgrade button // Remove upgrade button
if (config.get("options.removeUpgradeButton")) { if (config.get("options.removeUpgradeButton")) {
const upgradeButtton = document.querySelector('ytmusic-pivot-bar-item-renderer[tab-id="SPunlimited"]') const upgradeButton = document.querySelector('ytmusic-pivot-bar-item-renderer[tab-id="SPunlimited"]')
if (upgradeButtton) { if (upgradeButton) {
upgradeButtton.style.display = "none"; 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';
} }
} }
} }

View File

@ -1,17 +1,18 @@
const path = require("path"); const path = require("path");
const is = require("electron-is"); const is = require("electron-is");
const { isEnabled } = require("../config/plugins");
const iconPath = path.join(__dirname, "..", "assets", "youtube-music-tray.png"); const iconPath = path.join(__dirname, "..", "assets", "youtube-music-tray.png");
const customTitlebarPath = path.join(__dirname, "prompt-custom-titlebar.js"); const customTitlebarPath = path.join(__dirname, "prompt-custom-titlebar.js");
const promptOptions = is.macOS() ? { const promptOptions = !is.macOS() && isEnabled("in-app-menu") ? {
customStylesheet: "dark",
icon: iconPath
} : {
customStylesheet: "dark", customStylesheet: "dark",
// The following are used for custom titlebar // The following are used for custom titlebar
frame: false, frame: false,
customScript: customTitlebarPath, customScript: customTitlebarPath,
} : {
customStylesheet: "dark",
icon: iconPath
}; };
module.exports = () => promptOptions; module.exports = () => promptOptions;