Skip to content

Commit ee57415

Browse files
ttop32claude
andcommitted
Revert YouTube subtitle activation-timing changes
Restore src/subtitle/youtube.js to its df65dee state, undoing the activation speed / organic caption-ready wait / timeout changes (5a81c22, cbbffcc, 5e66012, ec2aacc). Back to the original fixed 4-5s wait before reloadCaption. Done as a forward revert (branch protection blocks force-push). Netflix <br/> and earlier work are kept. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent ec2aacc commit ee57415

1 file changed

Lines changed: 1 addition & 29 deletions

File tree

src/subtitle/youtube.js

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import $ from "jquery";
22
import memoize from "memoizee";
3-
import { waitUntil } from "async-wait-until";
43
import BaseVideo from "./baseVideo";
54
import * as util from "/src/util";
65
import { isRtl } from "/src/util/lang.js";
@@ -61,37 +60,10 @@ export default class Youtube extends BaseVideo {
6160
await this.interceptCaption(); // start caption intercept
6261
this.loadCaption(); // turn on caption for embed video
6362
this.setPlayerCaption(lang, tlang); //turn on caption on specified lang
64-
// wait organically until the caption system is actually loaded, instead of
65-
// a fixed delay: instant on fast loads, patient on slow ones (the old fixed
66-
// 4-5s wait was for slow player loads).
67-
await this.waitCaptionReady();
63+
await this.waitRandom(4000, 5000);
6864
this.reloadCaption(); //reset previous caption immediately
6965
}
7066

71-
// resolve once the player's caption tracklist is populated (caption system
72-
// ready). Returns as soon as it's ready, so the timeout only caps genuinely
73-
// stuck cases (no caption data / API change) before we reload anyway.
74-
static async waitCaptionReady() {
75-
try {
76-
await waitUntil(
77-
() => {
78-
try {
79-
var api = this.getPlayerApi().get(0);
80-
return !!(
81-
api?.getOption &&
82-
(api.getOption("captions", "tracklist") || []).length
83-
);
84-
} catch (e) {
85-
return false;
86-
}
87-
},
88-
{ timeout: 8000, intervalBetweenAttempts: 150 }
89-
);
90-
} catch (e) {
91-
// tracklist never appeared within the timeout — reload anyway
92-
}
93-
}
94-
9567
// player control advance================================
9668
static getPlayerApi() {
9769
return $(this.playerApiSelector);

0 commit comments

Comments
 (0)