From 771378fa5a2badd260c650fd8ab54f3e6f451445 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Thu, 17 Jul 2025 16:36:57 +0100 Subject: [PATCH 1/5] Debugging --- injected/src/features/duck-player-native.js | 2 +- .../src/features/duckplayer-native/youtube-errors.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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/youtube-errors.js b/injected/src/features/duckplayer-native/youtube-errors.js index 45936ca712..76191f3cfd 100644 --- a/injected/src/features/duckplayer-native/youtube-errors.js +++ b/injected/src/features/duckplayer-native/youtube-errors.js @@ -54,6 +54,13 @@ export function getErrorType(windowObject, signInRequiredSelector, logger) { if (!currentWindow.ytcfg) { logger?.warn('ytcfg missing!'); + setTimeout(() => { + if (currentWindow.ytcfg) { + logger?.log('Got ytcfg', currentWindow.ytcfg); + } else { + logger?.warn('ytcfg still missing!'); + } + }, 3000); } else { logger?.log('Got ytcfg', currentWindow.ytcfg); } @@ -72,16 +79,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; } } From a601bb478d921e175ad8f37b957ecd6b2aacbddf Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Thu, 17 Jul 2025 17:37:58 +0100 Subject: [PATCH 2/5] Dump window object --- injected/src/features/duckplayer-native/error-detection.js | 4 ++++ 1 file changed, 4 insertions(+) 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); } From 8667abb38f019fe33444c7b63f2fe8d560de3b4b Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Thu, 17 Jul 2025 18:08:52 +0100 Subject: [PATCH 3/5] Interval --- injected/src/features/duckplayer-native/youtube-errors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/injected/src/features/duckplayer-native/youtube-errors.js b/injected/src/features/duckplayer-native/youtube-errors.js index 76191f3cfd..37135cc79f 100644 --- a/injected/src/features/duckplayer-native/youtube-errors.js +++ b/injected/src/features/duckplayer-native/youtube-errors.js @@ -54,13 +54,13 @@ export function getErrorType(windowObject, signInRequiredSelector, logger) { if (!currentWindow.ytcfg) { logger?.warn('ytcfg missing!'); - setTimeout(() => { + setInterval(() => { if (currentWindow.ytcfg) { logger?.log('Got ytcfg', currentWindow.ytcfg); } else { logger?.warn('ytcfg still missing!'); } - }, 3000); + }, 300); } else { logger?.log('Got ytcfg', currentWindow.ytcfg); } From d9fd96cc5cb869976ded51cad1ea21203cb1fc37 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Thu, 17 Jul 2025 18:20:53 +0100 Subject: [PATCH 4/5] More logging --- injected/src/features/duckplayer-native/youtube-errors.js | 1 + 1 file changed, 1 insertion(+) diff --git a/injected/src/features/duckplayer-native/youtube-errors.js b/injected/src/features/duckplayer-native/youtube-errors.js index 37135cc79f..1dc81bd43d 100644 --- a/injected/src/features/duckplayer-native/youtube-errors.js +++ b/injected/src/features/duckplayer-native/youtube-errors.js @@ -59,6 +59,7 @@ export function getErrorType(windowObject, signInRequiredSelector, logger) { logger?.log('Got ytcfg', currentWindow.ytcfg); } else { logger?.warn('ytcfg still missing!'); + console.log('window.screenX, window.screenY', currentWindow.screenX, currentWindow.screenY); } }, 300); } else { From 929faade8d444b819cc82c9cb3759489a2fb3284 Mon Sep 17 00:00:00 2001 From: Marcos Gurgel Date: Thu, 17 Jul 2025 18:22:35 +0100 Subject: [PATCH 5/5] More logging --- injected/src/features/duckplayer-native/youtube-errors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/injected/src/features/duckplayer-native/youtube-errors.js b/injected/src/features/duckplayer-native/youtube-errors.js index 1dc81bd43d..c31544a13f 100644 --- a/injected/src/features/duckplayer-native/youtube-errors.js +++ b/injected/src/features/duckplayer-native/youtube-errors.js @@ -59,7 +59,7 @@ export function getErrorType(windowObject, signInRequiredSelector, logger) { logger?.log('Got ytcfg', currentWindow.ytcfg); } else { logger?.warn('ytcfg still missing!'); - console.log('window.screenX, window.screenY', currentWindow.screenX, currentWindow.screenY); + console.log('window.client', currentWindow.clientInformation); } }, 300); } else {