mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 02:31:45 +00:00
@ -102,7 +102,7 @@ export default createPlugin<
|
|||||||
api: null,
|
api: null,
|
||||||
config: null,
|
config: null,
|
||||||
setConfig: () => {},
|
setConfig: () => {},
|
||||||
async videoChangeListener() {
|
async captionsButtonClickListener() {
|
||||||
if (this.captionTrackList?.length) {
|
if (this.captionTrackList?.length) {
|
||||||
const currentCaptionTrack = this.api!.getOption<LanguageOptions>('captions', 'track');
|
const currentCaptionTrack = this.api!.getOption<LanguageOptions>('captions', 'track');
|
||||||
let currentIndex = currentCaptionTrack
|
let currentIndex = currentCaptionTrack
|
||||||
@ -130,8 +130,8 @@ export default createPlugin<
|
|||||||
setTimeout(() => this.api?.playVideo());
|
setTimeout(() => this.api?.playVideo());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
captionsButtonClickListener() {
|
videoChangeListener() {
|
||||||
if (this.config!.disableCaptions) {
|
if (this.config?.disableCaptions) {
|
||||||
setTimeout(() => this.api!.unloadModule('captions'), 100);
|
setTimeout(() => this.api!.unloadModule('captions'), 100);
|
||||||
this.captionsSettingsButton.style.display = 'none';
|
this.captionsSettingsButton.style.display = 'none';
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -41,6 +41,15 @@ export const startPlugin = <Config extends PluginConfig>(id: string, def: Plugin
|
|||||||
if (!lifecycle) return false;
|
if (!lifecycle) return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const defContext = def[options.ctx];
|
||||||
|
if (defContext && typeof defContext !== 'function') {
|
||||||
|
Object.entries(defContext)
|
||||||
|
.forEach(([key, value]) => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
||||||
|
if (typeof value === 'function') defContext[key as keyof typeof defContext] = value.bind(defContext);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
lifecycle.bind(def[options.ctx])(options.context as Config & typeof options.context);
|
lifecycle.bind(def[options.ctx])(options.context as Config & typeof options.context);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user