mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
fix: fix plugins cannot load config
This commit is contained in:
@ -104,7 +104,7 @@ export class PluginConfig<T extends OneOfDefaultConfigKey> {
|
||||
}
|
||||
|
||||
get<Key extends keyof ConfigType<T> = keyof ConfigType<T>>(key: Key): ConfigType<T>[Key] {
|
||||
return this.config[key];
|
||||
return this.config?.[key];
|
||||
}
|
||||
|
||||
set(key: keyof ConfigType<T>, value: ValueOf<ConfigType<T>>) {
|
||||
|
||||
@ -12,9 +12,7 @@ export const blockers = {
|
||||
|
||||
export const shouldUseBlocklists = async () => await config.get('blocker') !== blockers.InPlayer;
|
||||
|
||||
export default {
|
||||
export default Object.assign(config, {
|
||||
shouldUseBlocklists,
|
||||
blockers,
|
||||
get: config.get.bind(this),
|
||||
set: config.set.bind(this),
|
||||
};
|
||||
});
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { PluginConfig } from '../../config/dynamic';
|
||||
|
||||
const config = new PluginConfig('captions-selector', { enableFront: true });
|
||||
export default { ...config } as PluginConfig<'captions-selector'>;
|
||||
export default config;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { PluginConfig } from '../../config/dynamic';
|
||||
|
||||
const config = new PluginConfig('crossfade', { enableFront: true });
|
||||
export default { ...config } as PluginConfig<'crossfade'>;
|
||||
export default config;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { PluginConfig } from '../../config/dynamic';
|
||||
|
||||
const config = new PluginConfig('downloader');
|
||||
export default { ...config } as PluginConfig<'downloader'>;
|
||||
export default config;
|
||||
|
||||
@ -43,7 +43,8 @@ const menuObserver = new MutationObserver(() => {
|
||||
// TODO: re-enable once contextIsolation is set to true
|
||||
// contextBridge.exposeInMainWorld("downloader", {
|
||||
// download: () => {
|
||||
export const download = () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-member-access
|
||||
(global as any).download = () => {
|
||||
let videoUrl = getSongMenu()
|
||||
// Selector of first button which is always "Start Radio"
|
||||
?.querySelector('ytmusic-menu-navigation-item-renderer[tabindex="0"] #navigation-endpoint')
|
||||
|
||||
@ -2,4 +2,4 @@ import { PluginConfig } from '../../config/dynamic';
|
||||
|
||||
const config = new PluginConfig('notifications');
|
||||
|
||||
export default { ...config } as PluginConfig<'notifications'>;
|
||||
export default config;
|
||||
|
||||
@ -5,7 +5,6 @@ import { ipcMain, ipcRenderer } from 'electron';
|
||||
|
||||
import { ValueOf } from '../utils/type-utils';
|
||||
|
||||
|
||||
// Creates a DOM element from an HTML string
|
||||
export const ElementFromHtml = (html: string): HTMLElement => {
|
||||
const template = document.createElement('template');
|
||||
|
||||
Reference in New Issue
Block a user