diff --git a/injected/src/features/duck-player-native.js b/injected/src/features/duck-player-native.js index 70e7f60ccf..a2ef9b20da 100644 --- a/injected/src/features/duck-player-native.js +++ b/injected/src/features/duck-player-native.js @@ -43,7 +43,7 @@ export class DuckPlayerNativeFeature extends ContentFeature { const locale = args?.locale || args?.language || 'en'; const env = new Environment({ - debug: this.isDebug, + debug: this.isDebug || true, injectName: import.meta.injectName, platform: this.platform, locale, diff --git a/injected/src/features/duckplayer-native/error-detection.js b/injected/src/features/duckplayer-native/error-detection.js index 3f6d7167b7..88cc7db556 100644 --- a/injected/src/features/duckplayer-native/error-detection.js +++ b/injected/src/features/duckplayer-native/error-detection.js @@ -53,6 +53,8 @@ export class ErrorDetection { if (documentBody) { // Check if iframe already contains error if (checkForError(this.selectors.youtubeError, documentBody)) { + // @ts-expect-error ytcfg is not typed + console.log('Window Object', window, window.ytcfg); const error = getErrorType(window, this.selectors.signInRequiredError, this.logger); this.handleError(error); return; @@ -97,6 +99,8 @@ export class ErrorDetection { mutation.addedNodes.forEach((node) => { if (checkForError(this.selectors.youtubeError, node)) { this.logger.log('A node with an error has been added to the document:', node); + // @ts-expect-error ytcfg is not typed + console.log('Window Object', window, window.ytcfg); const error = getErrorType(window, this.selectors.signInRequiredError, this.logger); this.handleError(error); } diff --git a/injected/src/features/duckplayer-native/youtube-errors.js b/injected/src/features/duckplayer-native/youtube-errors.js index 45936ca712..c31544a13f 100644 --- a/injected/src/features/duckplayer-native/youtube-errors.js +++ b/injected/src/features/duckplayer-native/youtube-errors.js @@ -54,6 +54,14 @@ export function getErrorType(windowObject, signInRequiredSelector, logger) { if (!currentWindow.ytcfg) { logger?.warn('ytcfg missing!'); + setInterval(() => { + if (currentWindow.ytcfg) { + logger?.log('Got ytcfg', currentWindow.ytcfg); + } else { + logger?.warn('ytcfg still missing!'); + console.log('window.client', currentWindow.clientInformation); + } + }, 300); } else { logger?.log('Got ytcfg', currentWindow.ytcfg); } @@ -72,16 +80,20 @@ export function getErrorType(windowObject, signInRequiredSelector, logger) { previewPlayabilityStatus: { desktopLegacyAgeGateReason, status }, } = playerResponse; + console.log('playerResponse', playerResponse); // 1. Check for UNPLAYABLE status if (status === 'UNPLAYABLE') { + console.log('UNPLAYABLE'); // 1.1. Check for presence of desktopLegacyAgeGateReason if (desktopLegacyAgeGateReason === 1) { + console.log('AGE RESTRICTED'); logger?.log('AGE RESTRICTED ERROR'); return YOUTUBE_ERRORS.ageRestricted; } // 1.2. Fall back to embed not allowed error logger?.log('NO EMBED ERROR'); + console.log('NO EMBED'); return YOUTUBE_ERRORS.noEmbed; } }