mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 18:21:47 +00:00
xo --fix
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
/*
|
||||
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)
|
||||
*/
|
||||
let enabled = false;
|
||||
module.exports = (win,options) => {
|
||||
enabled = true;
|
||||
module.exports = () => {
|
||||
enabled = true;
|
||||
};
|
||||
|
||||
module.exports.enabled = () => {
|
||||
return enabled;
|
||||
return enabled;
|
||||
};
|
||||
@ -3,9 +3,9 @@ const { ipcRenderer } = require("electron");
|
||||
|
||||
module.exports = (options) => {
|
||||
setPlaybarOnwheel(options);
|
||||
setObserver(options);
|
||||
firstRun(options);
|
||||
setupObserver(options);
|
||||
setupArrowShortcuts(options);
|
||||
firstRun(options);
|
||||
};
|
||||
|
||||
function saveVolume(volume, options) {
|
||||
@ -45,11 +45,16 @@ function setPlaybarOnwheel(options) {
|
||||
}
|
||||
|
||||
function setupArrowShortcuts(options) {
|
||||
//change options from renderer to keep sync
|
||||
// Register shortcuts if enabled
|
||||
if (options.arrowsShortcut) {
|
||||
addListener();
|
||||
}
|
||||
|
||||
// Change options from renderer to keep sync
|
||||
ipcRenderer.on("setArrowsShortcut", (event, isEnabled) => {
|
||||
options.arrowsShortcut = isEnabled;
|
||||
setOptions("precise-volume", options);
|
||||
//can setting without restarting app
|
||||
// Can setting without restarting app
|
||||
if (isEnabled) {
|
||||
addListener();
|
||||
} else {
|
||||
@ -57,11 +62,6 @@ function setupArrowShortcuts(options) {
|
||||
}
|
||||
});
|
||||
|
||||
//register shortcuts if enabled
|
||||
if (options.arrowsShortcut) {
|
||||
addListener();
|
||||
}
|
||||
|
||||
function addListener() {
|
||||
window.addEventListener('keydown', callback);
|
||||
}
|
||||
@ -101,7 +101,7 @@ function changeVolume(increase, options) {
|
||||
}
|
||||
|
||||
// Save volume + Update the volume tooltip when volume-slider is manually changed
|
||||
function setObserver(options) {
|
||||
function setupObserver(options) {
|
||||
const observer = new MutationObserver(mutations => {
|
||||
for (const mutation of mutations) {
|
||||
// This checks that volume-slider was manually set
|
||||
@ -129,14 +129,13 @@ const tooltipTargets = [
|
||||
"#expand-volume"
|
||||
];
|
||||
|
||||
function setTooltip(newValue) {
|
||||
newValue += "%";
|
||||
function setTooltip(volume) {
|
||||
const tooltip = volume + "%";
|
||||
for (target of tooltipTargets) {
|
||||
document.querySelector(target).title = newValue;
|
||||
document.querySelector(target).title = tooltip;
|
||||
}
|
||||
}
|
||||
|
||||
function toPercent(volume) {
|
||||
return Math.round(Number.parseFloat(volume) * 100);
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
const { enabled } = require("./back")
|
||||
const { enabled } = require("./back");
|
||||
const { setOptions } = require("../../config/plugins");
|
||||
|
||||
module.exports = (win, options) => [
|
||||
@ -7,13 +7,13 @@ module.exports = (win, options) => [
|
||||
type: "checkbox",
|
||||
checked: !!options.arrowsShortcut,
|
||||
click: (item) => {
|
||||
//dynamically change setting if plugin enabled
|
||||
if (enabled()) {
|
||||
win.webContents.send("setArrowsShortcut", item.checked);
|
||||
} else { //fallback to usual method if disabled
|
||||
options.arrowsShortcut = item.checked;
|
||||
setOptions("precise-volume", options);
|
||||
}
|
||||
}
|
||||
// Dynamically change setting if plugin enabled
|
||||
if (enabled()) {
|
||||
win.webContents.send("setArrowsShortcut", item.checked);
|
||||
} else { // Fallback to usual method if disabled
|
||||
options.arrowsShortcut = item.checked;
|
||||
setOptions("precise-volume", options);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user