diff --git a/src/subtitle/YouTubeCaptionProvider.js b/src/subtitle/YouTubeCaptionProvider.js index 37f1942..5f16b69 100644 --- a/src/subtitle/YouTubeCaptionProvider.js +++ b/src/subtitle/YouTubeCaptionProvider.js @@ -78,7 +78,7 @@ class YouTubeCaptionProvider { } async #doubleClick() { - const button = this.#ytControls.querySelector( + const button = this.#ytControls?.querySelector( "button.ytp-subtitles-button" ); if (button) { @@ -135,7 +135,7 @@ class YouTubeCaptionProvider { } }; this.#toggleButton = toggleButton; - this.#ytControls.before(kissControls); + this.#ytControls?.before(kissControls); } #isSameLang(lang1, lang2) { @@ -754,7 +754,7 @@ class YouTubeCaptionProvider { const chunkEvents = chunks[i]; const chunkNum = i + 2; logger.info( - `Youtube Provider: Processing subtitle chunk ${chunkNum}/${chunks.length + 1}...` + `Youtube Provider: Processing subtitle chunk ${chunkNum}/${chunks.length + 1}: ${chunkEvents[0]?.start} --> ${chunkEvents[chunkEvents.length - 1]?.start}` ); let subtitlesForThisChunk = []; @@ -780,7 +780,7 @@ class YouTubeCaptionProvider { subtitlesForThisChunk = this.#formatSubtitles(chunkEvents, fromLang); } - if (this.#videoId !== videoId) { + if (this.#getVideoId() !== videoId) { logger.info("Youtube Provider: videoId changed!"); break; } diff --git a/src/subtitle/subtitle.js b/src/subtitle/subtitle.js index 95acc9c..e11a7c6 100644 --- a/src/subtitle/subtitle.js +++ b/src/subtitle/subtitle.js @@ -7,7 +7,7 @@ import { injectExternalJs } from "../libs/injector.js"; import { logger } from "../libs/log.js"; const providers = [ - { pattern: "https://www.youtube.com/watch", start: YouTubeInitializer }, + { pattern: "https://www.youtube.com/", start: YouTubeInitializer }, ]; export function runSubtitle({ href, setting }) {