Skip to content

Commit 97a8c22

Browse files
Fix MembersOnly chat
1 parent ae0d899 commit 97a8c22

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

src/context/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ export function parseMetadataFromWatch(html: string) {
152152
v.metadataBadgeRenderer.style === PurpleStyle.BadgeStyleTypeMembersOnly
153153
) || false;
154154

155+
// TODO: 2025-12-28: Force return continuations for init usage since YT change something I have no idea how to fix
156+
const continuations =
157+
initialData?.contents?.twoColumnWatchNextResults?.conversationBar
158+
?.liveChatRenderer?.continuations || [];
159+
155160
try {
156161
const playabilityStatus = findPlayabilityStatus(html);
157162
// even if playabilityStatus missing you can still have chat
@@ -177,6 +182,7 @@ export function parseMetadataFromWatch(html: string) {
177182
isUpcoming,
178183
isMembersOnly,
179184
metadata,
185+
continuations,
180186
};
181187
}
182188

src/interfaces/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export interface Credentials {
3939
*/
4040
DELEGATED_SESSION_ID?: string;
4141

42+
/**
43+
* Value of `SAPISID`
44+
*/
4245
"__Secure-1PAPISID"?: string;
4346
"__Secure-1PSID"?: string;
4447
"__Secure-1PSIDTS"?: string;

src/masterchat.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
VideoObject,
2626
YTCommentThreadRenderer,
2727
YTContinuationItem,
28+
YTReloadContinuation,
2829
} from "./interfaces";
2930
import {
3031
Action,
@@ -149,6 +150,8 @@ export class Masterchat extends EventEmitter {
149150
public title?: string;
150151
public videoMetadata?: VideoObject;
151152

153+
private continuations?: YTReloadContinuation[];
154+
152155
private axiosInstance: AxiosInstance;
153156
private listener: ChatListener | null = null;
154157
private listenerAbortion: AbortController = new AbortController();
@@ -443,6 +446,7 @@ export class Masterchat extends EventEmitter {
443446
this.isUpcoming = metadata.isUpcoming;
444447
this.isMembersOnly = metadata.isMembersOnly;
445448
this.videoMetadata = metadata.metadata;
449+
this.continuations = metadata.continuations;
446450
}
447451

448452
public async fetchMetadataFromWatch(id: string) {
@@ -677,16 +681,27 @@ export class Masterchat extends EventEmitter {
677681
let requestUrl: string = "";
678682
let requestBody;
679683
let payload: YTChatResponse;
684+
let self = this;
680685

681686
function applyNewLiveStatus(isLive: boolean) {
682687
requestUrl = isLive ? Constants.EP_GLC : Constants.EP_GLCR;
683688

684-
const continuation =
685-
typeof tokenOrOptions === "string"
686-
? tokenOrOptions
687-
: isLive
688-
? liveReloadContinuation(target, { top: topChat })
689-
: replayTimedContinuation(target, { top: topChat });
689+
let continuation: string;
690+
if (typeof tokenOrOptions === "string") {
691+
continuation = tokenOrOptions;
692+
} else if (isLive) {
693+
continuation = liveReloadContinuation(target, { top: topChat });
694+
} else if (self.isMembersOnly) {
695+
// TODO: 2025-12-28: Temp fix for MembersOnly as I have no idea how to update `replayTimedContinuation` for new continuation as YT changed something
696+
continuation = self.continuations?.[0]?.reloadContinuationData
697+
?.continuation as string;
698+
} else {
699+
continuation = replayTimedContinuation(target, { top: topChat });
700+
}
701+
702+
if (!continuation) {
703+
throw new DisabledChatError("continuation not found");
704+
}
690705

691706
requestBody = withContext({
692707
continuation,

0 commit comments

Comments
 (0)