fix: subtitle

This commit is contained in:
Gabe
2025-10-12 02:57:45 +08:00
parent 67149af64b
commit 2fa8917d5e
2 changed files with 5 additions and 5 deletions

View File

@@ -78,7 +78,7 @@ class YouTubeCaptionProvider {
} }
async #doubleClick() { async #doubleClick() {
const button = this.#ytControls.querySelector( const button = this.#ytControls?.querySelector(
"button.ytp-subtitles-button" "button.ytp-subtitles-button"
); );
if (button) { if (button) {
@@ -135,7 +135,7 @@ class YouTubeCaptionProvider {
} }
}; };
this.#toggleButton = toggleButton; this.#toggleButton = toggleButton;
this.#ytControls.before(kissControls); this.#ytControls?.before(kissControls);
} }
#isSameLang(lang1, lang2) { #isSameLang(lang1, lang2) {
@@ -754,7 +754,7 @@ class YouTubeCaptionProvider {
const chunkEvents = chunks[i]; const chunkEvents = chunks[i];
const chunkNum = i + 2; const chunkNum = i + 2;
logger.info( 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 = []; let subtitlesForThisChunk = [];
@@ -780,7 +780,7 @@ class YouTubeCaptionProvider {
subtitlesForThisChunk = this.#formatSubtitles(chunkEvents, fromLang); subtitlesForThisChunk = this.#formatSubtitles(chunkEvents, fromLang);
} }
if (this.#videoId !== videoId) { if (this.#getVideoId() !== videoId) {
logger.info("Youtube Provider: videoId changed!"); logger.info("Youtube Provider: videoId changed!");
break; break;
} }

View File

@@ -7,7 +7,7 @@ import { injectExternalJs } from "../libs/injector.js";
import { logger } from "../libs/log.js"; import { logger } from "../libs/log.js";
const providers = [ const providers = [
{ pattern: "https://www.youtube.com/watch", start: YouTubeInitializer }, { pattern: "https://www.youtube.com/", start: YouTubeInitializer },
]; ];
export function runSubtitle({ href, setting }) { export function runSubtitle({ href, setting }) {