mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
feat: run prettier
This commit is contained in:
@ -8,11 +8,11 @@ export const loadI18n = async () =>
|
|||||||
lng: 'en',
|
lng: 'en',
|
||||||
fallbackLng: 'en',
|
fallbackLng: 'en',
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false
|
escapeValue: false,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const setLanguage = async (language: string) => await changeLanguage(language);
|
export const setLanguage = async (language: string) =>
|
||||||
|
await changeLanguage(language);
|
||||||
|
|
||||||
export const t = i18t.bind(i18next);
|
export const t = i18t.bind(i18next);
|
||||||
|
|
||||||
|
|||||||
@ -322,7 +322,8 @@ async function createMainWindow() {
|
|||||||
winSize: String(winSize),
|
winSize: String(winSize),
|
||||||
displaySize: String(display.bounds),
|
displaySize: String(display.bounds),
|
||||||
windowPosition: String(windowPosition),
|
windowPosition: String(windowPosition),
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
win.setSize(scaledWidth, scaledHeight);
|
win.setSize(scaledWidth, scaledHeight);
|
||||||
@ -640,7 +641,10 @@ app.whenReady().then(async () => {
|
|||||||
const lastIndex = protocolArgv.endsWith('/') ? -1 : undefined;
|
const lastIndex = protocolArgv.endsWith('/') ? -1 : undefined;
|
||||||
const command = protocolArgv.slice(uri.length, lastIndex);
|
const command = protocolArgv.slice(uri.length, lastIndex);
|
||||||
if (is.dev()) {
|
if (is.dev()) {
|
||||||
console.debug(LoggerPrefix, t('main.console.second-instance.receive-command', { command }));
|
console.debug(
|
||||||
|
LoggerPrefix,
|
||||||
|
t('main.console.second-instance.receive-command', { command }),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleProtocol(command);
|
handleProtocol(command);
|
||||||
|
|||||||
@ -69,10 +69,10 @@ export const forceUnloadMainPlugin = async (
|
|||||||
plugin.backend)
|
plugin.backend)
|
||||||
) {
|
) {
|
||||||
delete loadedPluginMap[id];
|
delete loadedPluginMap[id];
|
||||||
console.log(LoggerPrefix, t(
|
console.log(
|
||||||
'common.console.plugins.unloaded',
|
LoggerPrefix,
|
||||||
{ pluginName: id },
|
t('common.console.plugins.unloaded', { pluginName: id }),
|
||||||
));
|
);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
console.log(
|
||||||
|
|||||||
@ -52,12 +52,14 @@ export const forceLoadMenuPlugin = async (id: string, win: BrowserWindow) => {
|
|||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
LoggerPrefix,
|
LoggerPrefix,
|
||||||
t('common.console.plugins.loaded', { pluginName: `${id}::menu` })
|
t('common.console.plugins.loaded', { pluginName: `${id}::menu` }),
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(
|
console.error(
|
||||||
LoggerPrefix,
|
LoggerPrefix,
|
||||||
t('common.console.plugins.initialize-failed', { pluginName: `${id}::menu` }),
|
t('common.console.plugins.initialize-failed', {
|
||||||
|
pluginName: `${id}::menu`,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
console.trace(err);
|
console.trace(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,10 @@ export const forceUnloadPreloadPlugin = async (id: string) => {
|
|||||||
);
|
);
|
||||||
delete loadedPluginMap[id];
|
delete loadedPluginMap[id];
|
||||||
} else {
|
} else {
|
||||||
console.error(LoggerPrefix, t('common.console.plugins.unload-failed', { pluginName: id }));
|
console.error(
|
||||||
|
LoggerPrefix,
|
||||||
|
t('common.console.plugins.unload-failed', { pluginName: id }),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,9 +65,15 @@ export const forceLoadPreloadPlugin = async (id: string) => {
|
|||||||
loadedPluginMap[id] = plugin;
|
loadedPluginMap[id] = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(LoggerPrefix, t('common.console.plugins.loaded', { pluginName: id }));
|
console.log(
|
||||||
|
LoggerPrefix,
|
||||||
|
t('common.console.plugins.loaded', { pluginName: id }),
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(LoggerPrefix, t('common.console.plugins.initialize-failed', { pluginName: id }));
|
console.error(
|
||||||
|
LoggerPrefix,
|
||||||
|
t('common.console.plugins.initialize-failed', { pluginName: id }),
|
||||||
|
);
|
||||||
console.trace(err);
|
console.trace(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,9 +4,10 @@ import { rendererPlugins } from 'virtual:plugins';
|
|||||||
|
|
||||||
import { LoggerPrefix, startPlugin, stopPlugin } from '@/utils';
|
import { LoggerPrefix, startPlugin, stopPlugin } from '@/utils';
|
||||||
|
|
||||||
|
import { t } from '@/i18n';
|
||||||
|
|
||||||
import type { RendererContext } from '@/types/contexts';
|
import type { RendererContext } from '@/types/contexts';
|
||||||
import type { PluginConfig, PluginDef } from '@/types/plugins';
|
import type { PluginConfig, PluginDef } from '@/types/plugins';
|
||||||
import { t } from '@/i18n';
|
|
||||||
|
|
||||||
const unregisterStyleMap: Record<string, (() => void)[]> = {};
|
const unregisterStyleMap: Record<string, (() => void)[]> = {};
|
||||||
const loadedPluginMap: Record<
|
const loadedPluginMap: Record<
|
||||||
@ -55,9 +56,15 @@ export const forceUnloadRendererPlugin = async (id: string) => {
|
|||||||
document.querySelector(`style#plugin-${id}`)?.remove();
|
document.querySelector(`style#plugin-${id}`)?.remove();
|
||||||
}
|
}
|
||||||
if (hasStopped || (hasStopped === null && plugin?.renderer)) {
|
if (hasStopped || (hasStopped === null && plugin?.renderer)) {
|
||||||
console.log(LoggerPrefix, t('common.console.plugins.unloaded', { pluginName: id }));
|
console.log(
|
||||||
|
LoggerPrefix,
|
||||||
|
t('common.console.plugins.unloaded', { pluginName: id }),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
console.error(LoggerPrefix, t('common.console.plugins.unload-failed', { pluginName: id }));
|
console.error(
|
||||||
|
LoggerPrefix,
|
||||||
|
t('common.console.plugins.unload-failed', { pluginName: id }),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -93,9 +100,15 @@ export const forceLoadRendererPlugin = async (id: string) => {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(LoggerPrefix, t('common.console.plugins.loaded', { pluginName: id }));
|
console.log(
|
||||||
|
LoggerPrefix,
|
||||||
|
t('common.console.plugins.loaded', { pluginName: id }),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log(LoggerPrefix, t('common.console.plugins.initialize-failed', { pluginName: id }));
|
console.log(
|
||||||
|
LoggerPrefix,
|
||||||
|
t('common.console.plugins.initialize-failed', { pluginName: id }),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
141
src/menu.ts
141
src/menu.ts
@ -24,7 +24,6 @@ import promptOptions from './providers/prompt-options';
|
|||||||
import { getAllMenuTemplate, loadAllMenuPlugins } from './loader/menu';
|
import { getAllMenuTemplate, loadAllMenuPlugins } from './loader/menu';
|
||||||
import { setLanguage, t } from '@/i18n';
|
import { setLanguage, t } from '@/i18n';
|
||||||
|
|
||||||
|
|
||||||
export type MenuTemplate = Electron.MenuItemConstructorOptions[];
|
export type MenuTemplate = Electron.MenuItemConstructorOptions[];
|
||||||
|
|
||||||
// True only if in-app-menu was loaded on launch
|
// True only if in-app-menu was loaded on launch
|
||||||
@ -82,7 +81,12 @@ export const mainMenuTemplate = async (
|
|||||||
{
|
{
|
||||||
label: pluginLabel,
|
label: pluginLabel,
|
||||||
submenu: [
|
submenu: [
|
||||||
pluginEnabledMenu(id, t('main.menu.plugins.enabled'), true, innerRefreshMenu),
|
pluginEnabledMenu(
|
||||||
|
id,
|
||||||
|
t('main.menu.plugins.enabled'),
|
||||||
|
true,
|
||||||
|
innerRefreshMenu,
|
||||||
|
),
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
...template,
|
...template,
|
||||||
],
|
],
|
||||||
@ -161,7 +165,9 @@ export const mainMenuTemplate = async (
|
|||||||
label: t('main.menu.options.submenu.visual-tweaks.label'),
|
label: t('main.menu.options.submenu.visual-tweaks.label'),
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.remove-upgrade-button'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.visual-tweaks.submenu.remove-upgrade-button',
|
||||||
|
),
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.get('options.removeUpgradeButton'),
|
checked: config.get('options.removeUpgradeButton'),
|
||||||
click(item: MenuItem) {
|
click(item: MenuItem) {
|
||||||
@ -172,10 +178,14 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.like-buttons.label'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.visual-tweaks.submenu.like-buttons.label',
|
||||||
|
),
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.like-buttons.default'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.visual-tweaks.submenu.like-buttons.default',
|
||||||
|
),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: !config.get('options.likeButtons'),
|
checked: !config.get('options.likeButtons'),
|
||||||
click() {
|
click() {
|
||||||
@ -183,7 +193,9 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.like-buttons.force-show'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.visual-tweaks.submenu.like-buttons.force-show',
|
||||||
|
),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: config.get('options.likeButtons') === 'force',
|
checked: config.get('options.likeButtons') === 'force',
|
||||||
click() {
|
click() {
|
||||||
@ -191,7 +203,9 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.like-buttons.hide'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.visual-tweaks.submenu.like-buttons.hide',
|
||||||
|
),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: config.get('options.likeButtons') === 'hide',
|
checked: config.get('options.likeButtons') === 'hide',
|
||||||
click() {
|
click() {
|
||||||
@ -201,10 +215,14 @@ export const mainMenuTemplate = async (
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.theme.label'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.visual-tweaks.submenu.theme.label',
|
||||||
|
),
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.theme.submenu.no-theme'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.visual-tweaks.submenu.theme.submenu.no-theme',
|
||||||
|
),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: config.get('options.themes')?.length === 0, // Todo rename "themes"
|
checked: config.get('options.themes')?.length === 0, // Todo rename "themes"
|
||||||
click() {
|
click() {
|
||||||
@ -213,7 +231,9 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.visual-tweaks.submenu.theme.submenu.import-css-file'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.visual-tweaks.submenu.theme.submenu.import-css-file',
|
||||||
|
),
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
async click() {
|
async click() {
|
||||||
const { filePaths } = await dialog.showOpenDialog({
|
const { filePaths } = await dialog.showOpenDialog({
|
||||||
@ -261,8 +281,12 @@ export const mainMenuTemplate = async (
|
|||||||
if (item.checked && !config.get('options.hideMenuWarned')) {
|
if (item.checked && !config.get('options.hideMenuWarned')) {
|
||||||
dialog.showMessageBox(win, {
|
dialog.showMessageBox(win, {
|
||||||
type: 'info',
|
type: 'info',
|
||||||
title: t('main.menu.options.submenu.hide-menu.dialog.title'),
|
title: t(
|
||||||
message: t('main.menu.options.submenu.hide-menu.dialog.message'),
|
'main.menu.options.submenu.hide-menu.dialog.title',
|
||||||
|
),
|
||||||
|
message: t(
|
||||||
|
'main.menu.options.submenu.hide-menu.dialog.message',
|
||||||
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -296,7 +320,9 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.tray.submenu.enabled-and-show-app'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.tray.submenu.enabled-and-show-app',
|
||||||
|
),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked:
|
checked:
|
||||||
config.get('options.tray') && config.get('options.appVisible'),
|
config.get('options.tray') && config.get('options.appVisible'),
|
||||||
@ -306,7 +332,9 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.tray.submenu.enabled-and-hide-app'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.tray.submenu.enabled-and-hide-app',
|
||||||
|
),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked:
|
checked:
|
||||||
config.get('options.tray') && !config.get('options.appVisible'),
|
config.get('options.tray') && !config.get('options.appVisible'),
|
||||||
@ -317,7 +345,9 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.tray.submenu.play-pause-on-click'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.tray.submenu.play-pause-on-click',
|
||||||
|
),
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.get('options.trayClickPlayPause'),
|
checked: config.get('options.trayClickPlayPause'),
|
||||||
click(item: MenuItem) {
|
click(item: MenuItem) {
|
||||||
@ -331,37 +361,42 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.language.label'),
|
label: t('main.menu.options.submenu.language.label'),
|
||||||
submenu: availableLanguages.map((lang): Electron.MenuItemConstructorOptions => ({
|
submenu: availableLanguages.map(
|
||||||
label: `${languageResources[lang].translation.language.name} (${languageResources[lang].translation.language['local-name']})`,
|
(lang): Electron.MenuItemConstructorOptions => ({
|
||||||
type: 'checkbox',
|
label: `${languageResources[lang].translation.language.name} (${languageResources[lang].translation.language['local-name']})`,
|
||||||
checked: config.get('options.language') === lang,
|
type: 'checkbox',
|
||||||
click() {
|
checked: config.get('options.language') === lang,
|
||||||
config.setMenuOption('options.language', lang);
|
click() {
|
||||||
refreshMenu(win);
|
config.setMenuOption('options.language', lang);
|
||||||
setLanguage(lang);
|
refreshMenu(win);
|
||||||
dialog.showMessageBox(
|
setLanguage(lang);
|
||||||
win,
|
dialog.showMessageBox(win, {
|
||||||
{
|
|
||||||
title: t('main.menu.options.submenu.language.dialog.title'),
|
title: t('main.menu.options.submenu.language.dialog.title'),
|
||||||
message: t('main.menu.options.submenu.language.dialog.message'),
|
message: t(
|
||||||
}
|
'main.menu.options.submenu.language.dialog.message',
|
||||||
);
|
),
|
||||||
},
|
});
|
||||||
})),
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.advanced-options.label'),
|
label: t('main.menu.options.submenu.advanced-options.label'),
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.advanced-options.submenu.set-proxy.label'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.advanced-options.submenu.set-proxy.label',
|
||||||
|
),
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
async click(item: MenuItem) {
|
async click(item: MenuItem) {
|
||||||
await setProxy(item, win);
|
await setProxy(item, win);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.advanced-options.submenu.override-user-agent'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.advanced-options.submenu.override-user-agent',
|
||||||
|
),
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.get('options.overrideUserAgent'),
|
checked: config.get('options.overrideUserAgent'),
|
||||||
click(item: MenuItem) {
|
click(item: MenuItem) {
|
||||||
@ -369,7 +404,9 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.advanced-options.submenu.disable-hardware-acceleration'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.advanced-options.submenu.disable-hardware-acceleration',
|
||||||
|
),
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.get('options.disableHardwareAcceleration'),
|
checked: config.get('options.disableHardwareAcceleration'),
|
||||||
click(item: MenuItem) {
|
click(item: MenuItem) {
|
||||||
@ -380,7 +417,9 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.advanced-options.submenu.restart-on-config-changes'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.advanced-options.submenu.restart-on-config-changes',
|
||||||
|
),
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.get('options.restartOnConfigChanges'),
|
checked: config.get('options.restartOnConfigChanges'),
|
||||||
click(item: MenuItem) {
|
click(item: MenuItem) {
|
||||||
@ -391,7 +430,9 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.advanced-options.submenu.auto-reset-app-cache'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.advanced-options.submenu.auto-reset-app-cache',
|
||||||
|
),
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.get('options.autoResetAppCache'),
|
checked: config.get('options.autoResetAppCache'),
|
||||||
click(item: MenuItem) {
|
click(item: MenuItem) {
|
||||||
@ -401,7 +442,9 @@ export const mainMenuTemplate = async (
|
|||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
is.macOS()
|
is.macOS()
|
||||||
? {
|
? {
|
||||||
label: t('main.menu.options.submenu.advanced-options.submenu.toggle-dev-tools'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.advanced-options.submenu.toggle-dev-tools',
|
||||||
|
),
|
||||||
// Cannot use "toggleDevTools" role in macOS
|
// Cannot use "toggleDevTools" role in macOS
|
||||||
click() {
|
click() {
|
||||||
const { webContents } = win;
|
const { webContents } = win;
|
||||||
@ -413,11 +456,15 @@ export const mainMenuTemplate = async (
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
label: t('main.menu.options.submenu.advanced-options.submenu.toggle-dev-tools'),
|
label: t(
|
||||||
role: 'toggleDevTools'
|
'main.menu.options.submenu.advanced-options.submenu.toggle-dev-tools',
|
||||||
},
|
),
|
||||||
|
role: 'toggleDevTools',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: t('main.menu.options.submenu.advanced-options.submenu.edit-config-json'),
|
label: t(
|
||||||
|
'main.menu.options.submenu.advanced-options.submenu.edit-config-json',
|
||||||
|
),
|
||||||
click() {
|
click() {
|
||||||
config.edit();
|
config.edit();
|
||||||
},
|
},
|
||||||
@ -533,13 +580,19 @@ export const setApplicationMenu = async (win: Electron.BrowserWindow) => {
|
|||||||
async function setProxy(item: Electron.MenuItem, win: BrowserWindow) {
|
async function setProxy(item: Electron.MenuItem, win: BrowserWindow) {
|
||||||
const output = await prompt(
|
const output = await prompt(
|
||||||
{
|
{
|
||||||
title: t('main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.title'),
|
title: t(
|
||||||
label: t('main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.label'),
|
'main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.title',
|
||||||
|
),
|
||||||
|
label: t(
|
||||||
|
'main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.label',
|
||||||
|
),
|
||||||
value: config.get('options.proxy'),
|
value: config.get('options.proxy'),
|
||||||
type: 'input',
|
type: 'input',
|
||||||
inputAttrs: {
|
inputAttrs: {
|
||||||
type: 'url',
|
type: 'url',
|
||||||
placeholder: t('main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.placeholder'),
|
placeholder: t(
|
||||||
|
'main.menu.options.submenu.advanced-options.submenu.set-proxy.prompt.placeholder',
|
||||||
|
),
|
||||||
},
|
},
|
||||||
width: 450,
|
width: 450,
|
||||||
...promptOptions(),
|
...promptOptions(),
|
||||||
|
|||||||
@ -44,9 +44,12 @@ export default createPlugin({
|
|||||||
{
|
{
|
||||||
label: t('plugins.ambient-mode.menu.smoothness-transition.label'),
|
label: t('plugins.ambient-mode.menu.smoothness-transition.label'),
|
||||||
submenu: interpolationTimeList.map((interpolationTime) => ({
|
submenu: interpolationTimeList.map((interpolationTime) => ({
|
||||||
label: t('plugins.ambient-mode.menu.smoothness-transition.submenu.during', {
|
label: t(
|
||||||
interpolationTime: interpolationTime / 1000,
|
'plugins.ambient-mode.menu.smoothness-transition.submenu.during',
|
||||||
}),
|
{
|
||||||
|
interpolationTime: interpolationTime / 1000,
|
||||||
|
},
|
||||||
|
),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: config.interpolationTime === interpolationTime,
|
checked: config.interpolationTime === interpolationTime,
|
||||||
click() {
|
click() {
|
||||||
@ -57,7 +60,9 @@ export default createPlugin({
|
|||||||
{
|
{
|
||||||
label: t('plugins.ambient-mode.menu.quality.label'),
|
label: t('plugins.ambient-mode.menu.quality.label'),
|
||||||
submenu: qualityList.map((quality) => ({
|
submenu: qualityList.map((quality) => ({
|
||||||
label: t('plugins.ambient-mode.menu.quality.submenu.pixels', { quality }),
|
label: t('plugins.ambient-mode.menu.quality.submenu.pixels', {
|
||||||
|
quality,
|
||||||
|
}),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: config.quality === quality,
|
checked: config.quality === quality,
|
||||||
click() {
|
click() {
|
||||||
@ -79,7 +84,9 @@ export default createPlugin({
|
|||||||
{
|
{
|
||||||
label: t('plugins.ambient-mode.menu.buffer.label'),
|
label: t('plugins.ambient-mode.menu.buffer.label'),
|
||||||
submenu: bufferList.map((buffer) => ({
|
submenu: bufferList.map((buffer) => ({
|
||||||
label: t('plugins.ambient-mode.menu.buffer.submenu.buffer', { buffer }),
|
label: t('plugins.ambient-mode.menu.buffer.submenu.buffer', {
|
||||||
|
buffer,
|
||||||
|
}),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: config.buffer === buffer,
|
checked: config.buffer === buffer,
|
||||||
click() {
|
click() {
|
||||||
@ -90,7 +97,9 @@ export default createPlugin({
|
|||||||
{
|
{
|
||||||
label: t('plugins.ambient-mode.menu.opacity.label'),
|
label: t('plugins.ambient-mode.menu.opacity.label'),
|
||||||
submenu: opacityList.map((opacity) => ({
|
submenu: opacityList.map((opacity) => ({
|
||||||
label: t('plugins.ambient-mode.menu.opacity.submenu.percent', { opacity: opacity * 100 }),
|
label: t('plugins.ambient-mode.menu.opacity.submenu.percent', {
|
||||||
|
opacity: opacity * 100,
|
||||||
|
}),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: config.opacity === opacity,
|
checked: config.opacity === opacity,
|
||||||
click() {
|
click() {
|
||||||
@ -101,7 +110,9 @@ export default createPlugin({
|
|||||||
{
|
{
|
||||||
label: t('plugins.ambient-mode.menu.blur-amount.label'),
|
label: t('plugins.ambient-mode.menu.blur-amount.label'),
|
||||||
submenu: blurAmountList.map((blur) => ({
|
submenu: blurAmountList.map((blur) => ({
|
||||||
label: t('plugins.ambient-mode.menu.blur-amount.submenu.pixels', { blurAmount: blur }),
|
label: t('plugins.ambient-mode.menu.blur-amount.submenu.pixels', {
|
||||||
|
blurAmount: blur,
|
||||||
|
}),
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
checked: config.blur === blur,
|
checked: config.blur === blur,
|
||||||
click() {
|
click() {
|
||||||
|
|||||||
@ -13,7 +13,9 @@ export default createBackend({
|
|||||||
{
|
{
|
||||||
title: t('plugins.captions-selector.prompt.selector.title'),
|
title: t('plugins.captions-selector.prompt.selector.title'),
|
||||||
label: t('plugins.captions-selector.prompt.selector.label', {
|
label: t('plugins.captions-selector.prompt.selector.label', {
|
||||||
language: captionLabels[currentIndex] || t('plugins.captions-selector.prompt.selector.none'),
|
language:
|
||||||
|
captionLabels[currentIndex] ||
|
||||||
|
t('plugins.captions-selector.prompt.selector.none'),
|
||||||
}),
|
}),
|
||||||
type: 'select',
|
type: 'select',
|
||||||
value: currentIndex,
|
value: currentIndex,
|
||||||
|
|||||||
@ -10,9 +10,10 @@ import { getNetFetchAsFetch } from '@/plugins/utils/main';
|
|||||||
import { createPlugin } from '@/utils';
|
import { createPlugin } from '@/utils';
|
||||||
import { VolumeFader } from './fader';
|
import { VolumeFader } from './fader';
|
||||||
|
|
||||||
import type { RendererContext } from '@/types/contexts';
|
|
||||||
import { t } from '@/i18n';
|
import { t } from '@/i18n';
|
||||||
|
|
||||||
|
import type { RendererContext } from '@/types/contexts';
|
||||||
|
|
||||||
export type CrossfadePluginConfig = {
|
export type CrossfadePluginConfig = {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
fadeInDuration: number;
|
fadeInDuration: number;
|
||||||
@ -72,7 +73,9 @@ export default createPlugin<
|
|||||||
type: 'multiInput',
|
type: 'multiInput',
|
||||||
multiInputOptions: [
|
multiInputOptions: [
|
||||||
{
|
{
|
||||||
label: t('plugins.crossfade.prompt.options.multi-input.fade-in-duration'),
|
label: t(
|
||||||
|
'plugins.crossfade.prompt.options.multi-input.fade-in-duration',
|
||||||
|
),
|
||||||
value: options.fadeInDuration,
|
value: options.fadeInDuration,
|
||||||
inputAttrs: {
|
inputAttrs: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
@ -82,7 +85,9 @@ export default createPlugin<
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('plugins.crossfade.prompt.options.multi-input.fade-out-duration'),
|
label: t(
|
||||||
|
'plugins.crossfade.prompt.options.multi-input.fade-out-duration',
|
||||||
|
),
|
||||||
value: options.fadeOutDuration,
|
value: options.fadeOutDuration,
|
||||||
inputAttrs: {
|
inputAttrs: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
@ -92,7 +97,9 @@ export default createPlugin<
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('plugins.crossfade.prompt.options.multi-input.seconds-before-end'),
|
label: t(
|
||||||
|
'plugins.crossfade.prompt.options.multi-input.seconds-before-end',
|
||||||
|
),
|
||||||
value: options.secondsBeforeEnd,
|
value: options.secondsBeforeEnd,
|
||||||
inputAttrs: {
|
inputAttrs: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
@ -101,10 +108,16 @@ export default createPlugin<
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('plugins.crossfade.prompt.options.multi-input.fade-scaling.label'),
|
label: t(
|
||||||
|
'plugins.crossfade.prompt.options.multi-input.fade-scaling.label',
|
||||||
|
),
|
||||||
selectOptions: {
|
selectOptions: {
|
||||||
linear: t('plugins.crossfade.prompt.options.multi-input.fade-scaling.linear'),
|
linear: t(
|
||||||
logarithmic: t('plugins.crossfade.prompt.options.multi-input.fade-scaling.logarithmic'),
|
'plugins.crossfade.prompt.options.multi-input.fade-scaling.linear',
|
||||||
|
),
|
||||||
|
logarithmic: t(
|
||||||
|
'plugins.crossfade.prompt.options.multi-input.fade-scaling.logarithmic',
|
||||||
|
),
|
||||||
},
|
},
|
||||||
value: options.fadeScaling,
|
value: options.fadeScaling,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -40,10 +40,7 @@ const resetInfo = () => {
|
|||||||
info.ready = false;
|
info.ready = false;
|
||||||
clearTimeout(clearActivity);
|
clearTimeout(clearActivity);
|
||||||
if (dev()) {
|
if (dev()) {
|
||||||
console.log(
|
console.log(LoggerPrefix, t('plugins.discord.backend.disconnected'));
|
||||||
LoggerPrefix,
|
|
||||||
t('plugins.discord.backend.disconnected')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const cb of refreshCallbacks) {
|
for (const cb of refreshCallbacks) {
|
||||||
@ -73,10 +70,7 @@ let window: Electron.BrowserWindow;
|
|||||||
export const connect = (showError = false) => {
|
export const connect = (showError = false) => {
|
||||||
if (info.rpc.isConnected) {
|
if (info.rpc.isConnected) {
|
||||||
if (dev()) {
|
if (dev()) {
|
||||||
console.log(
|
console.log(LoggerPrefix, t('plugins.discord.backend.already-connected'));
|
||||||
LoggerPrefix,
|
|
||||||
t('plugins.discord.backend.already-connected')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -214,10 +208,7 @@ export const backend = createBackend<
|
|||||||
|
|
||||||
info.rpc.on('connected', () => {
|
info.rpc.on('connected', () => {
|
||||||
if (dev()) {
|
if (dev()) {
|
||||||
console.log(
|
console.log(LoggerPrefix, t('plugins.discord.backend.connected'));
|
||||||
LoggerPrefix,
|
|
||||||
t('plugins.discord.backend.connected')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const cb of refreshCallbacks) {
|
for (const cb of refreshCallbacks) {
|
||||||
|
|||||||
@ -28,7 +28,9 @@ export const onMenu = async ({
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
label: isConnected() ? t('plugins.discord.menu.connected') : t('plugins.discord.menu.disconnected'),
|
label: isConnected()
|
||||||
|
? t('plugins.discord.menu.connected')
|
||||||
|
: t('plugins.discord.menu.disconnected'),
|
||||||
enabled: !isConnected(),
|
enabled: !isConnected(),
|
||||||
click: () => connect(),
|
click: () => connect(),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -181,19 +181,17 @@ async function downloadSongUnsafe(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sendFeedback(
|
sendFeedback(t('plugins.downloader.backend.feedback.downloading'), 2);
|
||||||
t('plugins.downloader.backend.feedback.downloading'),
|
|
||||||
2,
|
|
||||||
);
|
|
||||||
|
|
||||||
let id: string | null;
|
let id: string | null;
|
||||||
if (isId) {
|
if (isId) {
|
||||||
id = idOrUrl;
|
id = idOrUrl;
|
||||||
} else {
|
} else {
|
||||||
id = getVideoId(idOrUrl);
|
id = getVideoId(idOrUrl);
|
||||||
if (typeof id !== 'string') throw new Error(
|
if (typeof id !== 'string')
|
||||||
t('plugins.downloader.backend.feedback.video-id-not-found'),
|
throw new Error(
|
||||||
);
|
t('plugins.downloader.backend.feedback.video-id-not-found'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let info: TrackInfo | VideoInfo = await yt.music.getInfo(id);
|
let info: TrackInfo | VideoInfo = await yt.music.getInfo(id);
|
||||||
@ -325,9 +323,11 @@ async function downloadSongUnsafe(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendFeedback(null, -1);
|
sendFeedback(null, -1);
|
||||||
console.info(t('plugins.downloader.backend.feedback.done', {
|
console.info(
|
||||||
filePath,
|
t('plugins.downloader.backend.feedback.done', {
|
||||||
}));
|
filePath,
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function iterableStreamToTargetFile(
|
async function iterableStreamToTargetFile(
|
||||||
@ -357,10 +357,7 @@ async function iterableStreamToTargetFile(
|
|||||||
increasePlaylistProgress(ratio * 0.15);
|
increasePlaylistProgress(ratio * 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendFeedback(
|
sendFeedback(t('plugins.downloader.backend.feedback.loading'), 2); // Indefinite progress bar after download
|
||||||
t('plugins.downloader.backend.feedback.loading'),
|
|
||||||
2,
|
|
||||||
); // Indefinite progress bar after download
|
|
||||||
|
|
||||||
const buffer = Buffer.concat(chunks);
|
const buffer = Buffer.concat(chunks);
|
||||||
const safeVideoName = randomBytes(32).toString('hex');
|
const safeVideoName = randomBytes(32).toString('hex');
|
||||||
@ -399,9 +396,7 @@ async function iterableStreamToTargetFile(
|
|||||||
ffmpeg.FS('unlink', safeVideoName);
|
ffmpeg.FS('unlink', safeVideoName);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendFeedback(
|
sendFeedback(t('plugins.downloader.backend.feedback.saving'));
|
||||||
t('plugins.downloader.backend.feedback.saving'),
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return ffmpeg.FS('readFile', safeVideoNameWithExtension);
|
return ffmpeg.FS('readFile', safeVideoNameWithExtension);
|
||||||
@ -427,9 +422,7 @@ async function writeID3(
|
|||||||
sendFeedback: (str: string, value?: number) => void,
|
sendFeedback: (str: string, value?: number) => void,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
sendFeedback(
|
sendFeedback(t('plugins.downloader.backend.feedback.writing-id3'));
|
||||||
t('plugins.downloader.backend.feedback.writing-id3'),
|
|
||||||
);
|
|
||||||
const tags: NodeID3.Tags = {};
|
const tags: NodeID3.Tags = {};
|
||||||
|
|
||||||
// Create the metadata tags
|
// Create the metadata tags
|
||||||
@ -484,9 +477,9 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
|||||||
getPlaylistID(givenUrl) || getPlaylistID(new URL(playingUrl));
|
getPlaylistID(givenUrl) || getPlaylistID(new URL(playingUrl));
|
||||||
|
|
||||||
if (!playlistId) {
|
if (!playlistId) {
|
||||||
sendError(new Error(
|
sendError(
|
||||||
t('plugins.downloader.backend.feedback.playlist-id-not-found'),
|
new Error(t('plugins.downloader.backend.feedback.playlist-id-not-found')),
|
||||||
));
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,9 +490,7 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
|||||||
playlistId,
|
playlistId,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
sendFeedback(
|
sendFeedback(t('plugins.downloader.backend.feedback.getting-playlist-info'));
|
||||||
t('plugins.downloader.backend.feedback.getting-playlist-info'),
|
|
||||||
);
|
|
||||||
let playlist: Playlist;
|
let playlist: Playlist;
|
||||||
const items: YTNodes.MusicResponsiveListItem[] = [];
|
const items: YTNodes.MusicResponsiveListItem[] = [];
|
||||||
try {
|
try {
|
||||||
@ -519,9 +510,9 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!playlist || !playlist.items || playlist.items.length === 0) {
|
if (!playlist || !playlist.items || playlist.items.length === 0) {
|
||||||
sendError(new Error(
|
sendError(
|
||||||
t('plugins.downloader.backend.feedback.playlist-is-empty'),
|
new Error(t('plugins.downloader.backend.feedback.playlist-is-empty')),
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalPlaylistTitle = playlist.header?.title?.text;
|
const normalPlaylistTitle = playlist.header?.title?.text;
|
||||||
@ -558,11 +549,13 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
|||||||
const playlistFolder = join(folder, safePlaylistTitle);
|
const playlistFolder = join(folder, safePlaylistTitle);
|
||||||
if (existsSync(playlistFolder)) {
|
if (existsSync(playlistFolder)) {
|
||||||
if (!config.skipExisting) {
|
if (!config.skipExisting) {
|
||||||
sendError(new Error(
|
sendError(
|
||||||
t('plugins.downloader.backend.feedback.folder-already-exists', {
|
new Error(
|
||||||
playlistFolder,
|
t('plugins.downloader.backend.feedback.folder-already-exists', {
|
||||||
})
|
playlistFolder,
|
||||||
));
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -571,14 +564,22 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
|||||||
|
|
||||||
dialog.showMessageBox(win, {
|
dialog.showMessageBox(win, {
|
||||||
type: 'info',
|
type: 'info',
|
||||||
buttons: [t('plugins.downloader.backend.dialog.start-download-playlist.buttons.ok')],
|
buttons: [
|
||||||
|
t('plugins.downloader.backend.dialog.start-download-playlist.buttons.ok'),
|
||||||
|
],
|
||||||
title: t('plugins.downloader.backend.dialog.start-download-playlist.title'),
|
title: t('plugins.downloader.backend.dialog.start-download-playlist.title'),
|
||||||
message: t('plugins.downloader.backend.dialog.start-download-playlist.message', {
|
message: t(
|
||||||
playlistTitle,
|
'plugins.downloader.backend.dialog.start-download-playlist.message',
|
||||||
}),
|
{
|
||||||
detail: t('plugins.downloader.backend.dialog.start-download-playlist.detail', {
|
playlistTitle,
|
||||||
playlistSize: items.length,
|
},
|
||||||
}),
|
),
|
||||||
|
detail: t(
|
||||||
|
'plugins.downloader.backend.dialog.start-download-playlist.detail',
|
||||||
|
{
|
||||||
|
playlistSize: items.length,
|
||||||
|
},
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (is.dev()) {
|
if (is.dev()) {
|
||||||
@ -611,7 +612,7 @@ export async function downloadPlaylist(givenUrl?: string | URL) {
|
|||||||
t('plugins.downloader.backend.feedback.downloading-counter', {
|
t('plugins.downloader.backend.feedback.downloading-counter', {
|
||||||
current: counter,
|
current: counter,
|
||||||
total: items.length,
|
total: items.length,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
const trackId = isAlbum ? counter : undefined;
|
const trackId = isAlbum ? counter : undefined;
|
||||||
await downloadSongFromId(
|
await downloadSongFromId(
|
||||||
|
|||||||
@ -4,11 +4,12 @@ import { downloadPlaylist } from './main';
|
|||||||
import { defaultMenuDownloadLabel, getFolder } from './main/utils';
|
import { defaultMenuDownloadLabel, getFolder } from './main/utils';
|
||||||
import { DefaultPresetList } from './types';
|
import { DefaultPresetList } from './types';
|
||||||
|
|
||||||
|
import { t } from '@/i18n';
|
||||||
|
|
||||||
import type { MenuContext } from '@/types/contexts';
|
import type { MenuContext } from '@/types/contexts';
|
||||||
import type { MenuTemplate } from '@/menu';
|
import type { MenuTemplate } from '@/menu';
|
||||||
|
|
||||||
import type { DownloaderPluginConfig } from './index';
|
import type { DownloaderPluginConfig } from './index';
|
||||||
import { t } from '@/i18n';
|
|
||||||
|
|
||||||
export const onMenu = async ({
|
export const onMenu = async ({
|
||||||
getConfig,
|
getConfig,
|
||||||
|
|||||||
@ -6,12 +6,13 @@ import { getSongInfo } from '@/providers/song-info-front';
|
|||||||
|
|
||||||
import { LoggerPrefix } from '@/utils';
|
import { LoggerPrefix } from '@/utils';
|
||||||
|
|
||||||
|
import { t } from '@/i18n';
|
||||||
|
|
||||||
import { ElementFromHtml } from '../utils/renderer';
|
import { ElementFromHtml } from '../utils/renderer';
|
||||||
|
|
||||||
import type { RendererContext } from '@/types/contexts';
|
import type { RendererContext } from '@/types/contexts';
|
||||||
|
|
||||||
import type { DownloaderPluginConfig } from './index';
|
import type { DownloaderPluginConfig } from './index';
|
||||||
import { t } from '@/i18n';
|
|
||||||
|
|
||||||
let menu: Element | null = null;
|
let menu: Element | null = null;
|
||||||
let progress: Element | null = null;
|
let progress: Element | null = null;
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import { LoggerPrefix } from '@/utils';
|
import { LoggerPrefix } from '@/utils';
|
||||||
|
|
||||||
|
import { t } from '@/i18n';
|
||||||
|
|
||||||
import type { SongInfo } from '@/providers/song-info';
|
import type { SongInfo } from '@/providers/song-info';
|
||||||
import type { RendererContext } from '@/types/contexts';
|
import type { RendererContext } from '@/types/contexts';
|
||||||
import type { LyricsGeniusPluginConfig } from '@/plugins/lyrics-genius/index';
|
import type { LyricsGeniusPluginConfig } from '@/plugins/lyrics-genius/index';
|
||||||
import { t } from '@/i18n';
|
|
||||||
|
|
||||||
export const onRendererLoad = ({
|
export const onRendererLoad = ({
|
||||||
ipc: { invoke, on },
|
ipc: { invoke, on },
|
||||||
|
|||||||
@ -59,21 +59,27 @@ export const onMenu = async ({
|
|||||||
label: t('plugins.notifications.menu.interactive-settings.label'),
|
label: t('plugins.notifications.menu.interactive-settings.label'),
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: t('plugins.notifications.menu.interactive-settings.submenu.tray-controls'),
|
label: t(
|
||||||
|
'plugins.notifications.menu.interactive-settings.submenu.tray-controls',
|
||||||
|
),
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.trayControls,
|
checked: config.trayControls,
|
||||||
click: (item: MenuItem) =>
|
click: (item: MenuItem) =>
|
||||||
setConfig({ trayControls: item.checked }),
|
setConfig({ trayControls: item.checked }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('plugins.notifications.menu.interactive-settings.submenu.hide-button-text'),
|
label: t(
|
||||||
|
'plugins.notifications.menu.interactive-settings.submenu.hide-button-text',
|
||||||
|
),
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.hideButtonText,
|
checked: config.hideButtonText,
|
||||||
click: (item: MenuItem) =>
|
click: (item: MenuItem) =>
|
||||||
setConfig({ hideButtonText: item.checked }),
|
setConfig({ hideButtonText: item.checked }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('plugins.notifications.menu.interactive-settings.submenu.refresh-on-play-pause'),
|
label: t(
|
||||||
|
'plugins.notifications.menu.interactive-settings.submenu.refresh-on-play-pause',
|
||||||
|
),
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.refreshOnPlayPause,
|
checked: config.refreshOnPlayPause,
|
||||||
click: (item: MenuItem) =>
|
click: (item: MenuItem) =>
|
||||||
|
|||||||
@ -55,7 +55,9 @@ export const onMenu = async ({
|
|||||||
keybindOptions: [
|
keybindOptions: [
|
||||||
{
|
{
|
||||||
value: 'hotkey',
|
value: 'hotkey',
|
||||||
label: t('plugins.picture-in-picture.menu.prompt.keybind-options.hotkey'),
|
label: t(
|
||||||
|
'plugins.picture-in-picture.menu.prompt.keybind-options.hotkey',
|
||||||
|
),
|
||||||
default: config.hotkey,
|
default: config.hotkey,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@ -44,7 +44,9 @@
|
|||||||
class="text style-scope ytmusic-menu-navigation-item-renderer"
|
class="text style-scope ytmusic-menu-navigation-item-renderer"
|
||||||
id="ytmcustom-pip"
|
id="ytmcustom-pip"
|
||||||
>
|
>
|
||||||
<ytmd-trans key="plugins.picture-in-picture.templates.button"></ytmd-trans>
|
<ytmd-trans
|
||||||
|
key="plugins.picture-in-picture.templates.button"
|
||||||
|
></ytmd-trans>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -83,7 +83,8 @@
|
|||||||
class="text style-scope ytmusic-menu-navigation-item-renderer"
|
class="text style-scope ytmusic-menu-navigation-item-renderer"
|
||||||
id="ytmcustom-playback-speed"
|
id="ytmcustom-playback-speed"
|
||||||
>
|
>
|
||||||
<ytmd-trans key="plugins.playback-speed.templates.button"></ytmd-trans> (<span id="playback-speed-value">1</span>)
|
<ytmd-trans key="plugins.playback-speed.templates.button"></ytmd-trans>
|
||||||
|
(<span id="playback-speed-value">1</span>)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -103,12 +103,16 @@ export default createPlugin({
|
|||||||
type: 'keybind',
|
type: 'keybind',
|
||||||
keybindOptions: [
|
keybindOptions: [
|
||||||
kb(
|
kb(
|
||||||
t('plugins.precise-volume.prompt.global-shortcuts.keybind-options.increase'),
|
t(
|
||||||
|
'plugins.precise-volume.prompt.global-shortcuts.keybind-options.increase',
|
||||||
|
),
|
||||||
'volumeUp',
|
'volumeUp',
|
||||||
options.globalShortcuts?.volumeUp,
|
options.globalShortcuts?.volumeUp,
|
||||||
),
|
),
|
||||||
kb(
|
kb(
|
||||||
t('plugins.precise-volume.prompt.global-shortcuts.keybind-options.decrease'),
|
t(
|
||||||
|
'plugins.precise-volume.prompt.global-shortcuts.keybind-options.decrease',
|
||||||
|
),
|
||||||
'volumeDown',
|
'volumeDown',
|
||||||
options.globalShortcuts?.volumeDown,
|
options.globalShortcuts?.volumeDown,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -24,11 +24,18 @@ export default createPlugin({
|
|||||||
type: 'question',
|
type: 'question',
|
||||||
buttons: qualityLabels,
|
buttons: qualityLabels,
|
||||||
defaultId: currentIndex,
|
defaultId: currentIndex,
|
||||||
title: t('plugins.quality-changer.backend.dialog.quality-changer.title'),
|
title: t(
|
||||||
message: t('plugins.quality-changer.backend.dialog.quality-changer.message'),
|
'plugins.quality-changer.backend.dialog.quality-changer.title',
|
||||||
detail: t('plugins.quality-changer.backend.dialog.quality-changer.detail', {
|
),
|
||||||
quality: qualityLabels[currentIndex],
|
message: t(
|
||||||
}),
|
'plugins.quality-changer.backend.dialog.quality-changer.message',
|
||||||
|
),
|
||||||
|
detail: t(
|
||||||
|
'plugins.quality-changer.backend.dialog.quality-changer.detail',
|
||||||
|
{
|
||||||
|
quality: qualityLabels[currentIndex],
|
||||||
|
},
|
||||||
|
),
|
||||||
cancelId: -1,
|
cancelId: -1,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -36,9 +36,21 @@ export const onMenu = async ({
|
|||||||
type: 'keybind',
|
type: 'keybind',
|
||||||
keybindOptions: [
|
keybindOptions: [
|
||||||
// If default=undefined then no default is used
|
// If default=undefined then no default is used
|
||||||
kb(t('plugins.shortcuts.prompt.keybind.keybind-options.previous'), 'previous', config.global?.previous),
|
kb(
|
||||||
kb(t('plugins.shortcuts.prompt.keybind.keybind-options.play-pause'), 'playPause', config.global?.playPause),
|
t('plugins.shortcuts.prompt.keybind.keybind-options.previous'),
|
||||||
kb(t('plugins.shortcuts.prompt.keybind.keybind-options.next'), 'next', config.global?.next),
|
'previous',
|
||||||
|
config.global?.previous,
|
||||||
|
),
|
||||||
|
kb(
|
||||||
|
t('plugins.shortcuts.prompt.keybind.keybind-options.play-pause'),
|
||||||
|
'playPause',
|
||||||
|
config.global?.playPause,
|
||||||
|
),
|
||||||
|
kb(
|
||||||
|
t('plugins.shortcuts.prompt.keybind.keybind-options.next'),
|
||||||
|
'next',
|
||||||
|
config.global?.next,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
height: 270,
|
height: 270,
|
||||||
...promptOptions(),
|
...promptOptions(),
|
||||||
|
|||||||
@ -114,12 +114,16 @@ export default (api: YoutubePlayer) => {
|
|||||||
pause: (e: Event) => playPausedHandler(e, 'pause'),
|
pause: (e: Event) => playPausedHandler(e, 'pause'),
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/require-await
|
const videoEventDispatcher = async (
|
||||||
const videoEventDispatcher = async (name: string, videoData: VideoDataChangeValue) => document.dispatchEvent(
|
name: string,
|
||||||
new CustomEvent<VideoDataChanged>('videodatachange', {
|
videoData: VideoDataChangeValue,
|
||||||
detail: { name, videoData },
|
// eslint-disable-next-line @typescript-eslint/require-await
|
||||||
}),
|
) =>
|
||||||
);
|
document.dispatchEvent(
|
||||||
|
new CustomEvent<VideoDataChanged>('videodatachange', {
|
||||||
|
detail: { name, videoData },
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
const waitingEvent = new Set<string>();
|
const waitingEvent = new Set<string>();
|
||||||
// Name = "dataloaded" and abit later "dataupdated"
|
// Name = "dataloaded" and abit later "dataupdated"
|
||||||
|
|||||||
@ -159,18 +159,21 @@ async function onApiLoaded() {
|
|||||||
* YouTube Music still using ES5, so we need to define custom elements using ES5 style
|
* YouTube Music still using ES5, so we need to define custom elements using ES5 style
|
||||||
*/
|
*/
|
||||||
const defineYTMDTransElements = () => {
|
const defineYTMDTransElements = () => {
|
||||||
const YTMDTrans = function() {};
|
const YTMDTrans = function () {};
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||||
YTMDTrans.prototype = Object.create(HTMLElement.prototype);
|
YTMDTrans.prototype = Object.create(HTMLElement.prototype);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
YTMDTrans.prototype.connectedCallback = function() {
|
YTMDTrans.prototype.connectedCallback = function () {
|
||||||
const that = (this as HTMLElement);
|
const that = this as HTMLElement;
|
||||||
const key = that.getAttribute('key');
|
const key = that.getAttribute('key');
|
||||||
if (key) {
|
if (key) {
|
||||||
that.innerHTML = i18t(key);
|
that.innerHTML = i18t(key);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
customElements.define('ytmd-trans', YTMDTrans as unknown as CustomElementConstructor);
|
customElements.define(
|
||||||
|
'ytmd-trans',
|
||||||
|
YTMDTrans as unknown as CustomElementConstructor,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|||||||
4
src/reset.d.ts
vendored
4
src/reset.d.ts
vendored
@ -32,8 +32,8 @@ declare global {
|
|||||||
togglePictureInPicture: () => void;
|
togglePictureInPicture: () => void;
|
||||||
reload: () => void;
|
reload: () => void;
|
||||||
i18n: {
|
i18n: {
|
||||||
t: typeof t,
|
t: typeof t;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -119,13 +119,10 @@ export const startPlugin = async <Config extends PluginConfig>(
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(
|
console.error(
|
||||||
LoggerPrefix,
|
LoggerPrefix,
|
||||||
t(
|
t('common.console.plugins.execute-failed', {
|
||||||
'common.console.plugins.execute-failed',
|
pluginName: id,
|
||||||
{
|
contextName: options.ctx,
|
||||||
pluginName: id,
|
}),
|
||||||
contextName: options.ctx,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
console.trace(err);
|
console.trace(err);
|
||||||
return false;
|
return false;
|
||||||
@ -166,13 +163,10 @@ export const stopPlugin = async <Config extends PluginConfig>(
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(
|
console.error(
|
||||||
LoggerPrefix,
|
LoggerPrefix,
|
||||||
t(
|
t('common.console.plugins.execute-failed', {
|
||||||
'common.console.plugins.execute-failed',
|
pluginName: id,
|
||||||
{
|
contextName: options.ctx,
|
||||||
pluginName: id,
|
}),
|
||||||
contextName: options.ctx,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
console.trace(err);
|
console.trace(err);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user