mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
@ -28,12 +28,11 @@ interface CaptionsSelectorConfig {
|
||||
lastCaptionsCode: string;
|
||||
}
|
||||
|
||||
const captionsSettingsButton = ElementFromHtml(CaptionsSettingsButtonHTML);
|
||||
|
||||
export default createPlugin<
|
||||
unknown,
|
||||
unknown,
|
||||
{
|
||||
captionsSettingsButton: HTMLElement;
|
||||
captionTrackList: LanguageOptions[] | null;
|
||||
api: YoutubePlayer | null;
|
||||
config: CaptionsSelectorConfig | null;
|
||||
@ -98,6 +97,7 @@ export default createPlugin<
|
||||
},
|
||||
|
||||
renderer: {
|
||||
captionsSettingsButton: ElementFromHtml(CaptionsSettingsButtonHTML),
|
||||
captionTrackList: null,
|
||||
api: null,
|
||||
config: null,
|
||||
@ -133,7 +133,7 @@ export default createPlugin<
|
||||
captionsButtonClickListener() {
|
||||
if (this.config!.disableCaptions) {
|
||||
setTimeout(() => this.api!.unloadModule('captions'), 100);
|
||||
captionsSettingsButton.style.display = 'none';
|
||||
this.captionsSettingsButton.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ export default createPlugin<
|
||||
});
|
||||
}
|
||||
|
||||
captionsSettingsButton.style.display = this.captionTrackList?.length
|
||||
this.captionsSettingsButton.style.display = this.captionTrackList?.length
|
||||
? 'inline-block'
|
||||
: 'none';
|
||||
}, 250);
|
||||
@ -158,20 +158,20 @@ export default createPlugin<
|
||||
this.setConfig = setConfig;
|
||||
},
|
||||
stop() {
|
||||
document.querySelector('.right-controls-buttons')?.removeChild(captionsSettingsButton);
|
||||
document.querySelector('.right-controls-buttons')?.removeChild(this.captionsSettingsButton);
|
||||
document.querySelector<YoutubePlayer & HTMLElement>('#movie_player')?.unloadModule('captions');
|
||||
document.querySelector('video')?.removeEventListener('srcChanged', this.videoChangeListener);
|
||||
captionsSettingsButton.removeEventListener('click', this.captionsButtonClickListener);
|
||||
this.captionsSettingsButton.removeEventListener('click', this.captionsButtonClickListener);
|
||||
},
|
||||
onPlayerApiReady(playerApi) {
|
||||
this.api = playerApi;
|
||||
|
||||
document.querySelector('.right-controls-buttons')?.append(captionsSettingsButton);
|
||||
document.querySelector('.right-controls-buttons')?.append(this.captionsSettingsButton);
|
||||
|
||||
this.captionTrackList = this.api.getOption<LanguageOptions[]>('captions', 'tracklist') ?? [];
|
||||
|
||||
document.querySelector('video')?.addEventListener('srcChanged', this.videoChangeListener);
|
||||
captionsSettingsButton.addEventListener('click', this.captionsButtonClickListener);
|
||||
this.captionsSettingsButton.addEventListener('click', this.captionsButtonClickListener);
|
||||
},
|
||||
onConfigChange(newConfig) {
|
||||
this.config = newConfig;
|
||||
|
||||
@ -36,7 +36,7 @@ import { cache } from '@/providers/decorators';
|
||||
|
||||
import { YoutubeFormatList, type Preset, DefaultPresetList } from '../types';
|
||||
|
||||
import { defaultConfig, type DownloaderPluginConfig } from '../index';
|
||||
import type { DownloaderPluginConfig } from '../index';
|
||||
|
||||
import type { BackendContext } from '@/types/contexts';
|
||||
|
||||
@ -91,7 +91,7 @@ export const getCookieFromWindow = async (win: BrowserWindow) => {
|
||||
.join(';');
|
||||
};
|
||||
|
||||
let config: DownloaderPluginConfig = defaultConfig;
|
||||
let config: DownloaderPluginConfig;
|
||||
|
||||
export const onMainLoad = async ({ window: _win, getConfig, ipc }: BackendContext<DownloaderPluginConfig>) => {
|
||||
win = _win;
|
||||
|
||||
@ -5,12 +5,12 @@ import is from 'electron-is';
|
||||
import { notificationImage } from './utils';
|
||||
import interactive from './interactive';
|
||||
|
||||
import { defaultConfig, type NotificationsPluginConfig } from './index';
|
||||
import registerCallback, { type SongInfo } from '@/providers/song-info';
|
||||
|
||||
import type { NotificationsPluginConfig } from './index';
|
||||
import type { BackendContext } from '@/types/contexts';
|
||||
|
||||
let config: NotificationsPluginConfig = defaultConfig;
|
||||
let config: NotificationsPluginConfig;
|
||||
|
||||
const notify = (info: SongInfo) => {
|
||||
// Send the notification
|
||||
|
||||
Reference in New Issue
Block a user