fix: fix plugins cannot load config

This commit is contained in:
Su-Yong
2023-09-04 03:04:44 +09:00
parent 5069913c56
commit b5472c11df
8 changed files with 9 additions and 11 deletions

View File

@ -104,7 +104,7 @@ export class PluginConfig<T extends OneOfDefaultConfigKey> {
} }
get<Key extends keyof ConfigType<T> = keyof ConfigType<T>>(key: Key): ConfigType<T>[Key] { 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>>) { set(key: keyof ConfigType<T>, value: ValueOf<ConfigType<T>>) {

View File

@ -12,9 +12,7 @@ export const blockers = {
export const shouldUseBlocklists = async () => await config.get('blocker') !== blockers.InPlayer; export const shouldUseBlocklists = async () => await config.get('blocker') !== blockers.InPlayer;
export default { export default Object.assign(config, {
shouldUseBlocklists, shouldUseBlocklists,
blockers, blockers,
get: config.get.bind(this), });
set: config.set.bind(this),
};

View File

@ -1,4 +1,4 @@
import { PluginConfig } from '../../config/dynamic'; import { PluginConfig } from '../../config/dynamic';
const config = new PluginConfig('captions-selector', { enableFront: true }); const config = new PluginConfig('captions-selector', { enableFront: true });
export default { ...config } as PluginConfig<'captions-selector'>; export default config;

View File

@ -1,4 +1,4 @@
import { PluginConfig } from '../../config/dynamic'; import { PluginConfig } from '../../config/dynamic';
const config = new PluginConfig('crossfade', { enableFront: true }); const config = new PluginConfig('crossfade', { enableFront: true });
export default { ...config } as PluginConfig<'crossfade'>; export default config;

View File

@ -1,4 +1,4 @@
import { PluginConfig } from '../../config/dynamic'; import { PluginConfig } from '../../config/dynamic';
const config = new PluginConfig('downloader'); const config = new PluginConfig('downloader');
export default { ...config } as PluginConfig<'downloader'>; export default config;

View File

@ -43,7 +43,8 @@ const menuObserver = new MutationObserver(() => {
// TODO: re-enable once contextIsolation is set to true // TODO: re-enable once contextIsolation is set to true
// contextBridge.exposeInMainWorld("downloader", { // contextBridge.exposeInMainWorld("downloader", {
// download: () => { // 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() let videoUrl = getSongMenu()
// Selector of first button which is always "Start Radio" // Selector of first button which is always "Start Radio"
?.querySelector('ytmusic-menu-navigation-item-renderer[tabindex="0"] #navigation-endpoint') ?.querySelector('ytmusic-menu-navigation-item-renderer[tabindex="0"] #navigation-endpoint')

View File

@ -2,4 +2,4 @@ import { PluginConfig } from '../../config/dynamic';
const config = new PluginConfig('notifications'); const config = new PluginConfig('notifications');
export default { ...config } as PluginConfig<'notifications'>; export default config;

View File

@ -5,7 +5,6 @@ import { ipcMain, ipcRenderer } from 'electron';
import { ValueOf } from '../utils/type-utils'; import { ValueOf } from '../utils/type-utils';
// Creates a DOM element from an HTML string // Creates a DOM element from an HTML string
export const ElementFromHtml = (html: string): HTMLElement => { export const ElementFromHtml = (html: string): HTMLElement => {
const template = document.createElement('template'); const template = document.createElement('template');