From c25ffdb51754ec575a9bc2c9c7c80e000539055d Mon Sep 17 00:00:00 2001 From: ImprovedTube Date: Sun, 28 Jul 2024 22:25:40 +0200 Subject: [PATCH] thanks to #2421 @raszpl --- .../web-accessible/www.youtube.com/appearance.js | 14 ++++++++++++-- js&css/web-accessible/www.youtube.com/shortcuts.js | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/js&css/web-accessible/www.youtube.com/appearance.js b/js&css/web-accessible/www.youtube.com/appearance.js index 50594ff22..1353526ac 100644 --- a/js&css/web-accessible/www.youtube.com/appearance.js +++ b/js&css/web-accessible/www.youtube.com/appearance.js @@ -306,12 +306,22 @@ ImprovedTube.commentsSidebar = function () { if (ImprovedTube.storage.comments_s TRANSCRIPT --------------------------------------------------------------*/ ImprovedTube.transcript = function (el) { if (ImprovedTube.storage.transcript === true) { - el.querySelector('*[target-id*=transcript]')?.removeAttribute('visibility');} } + const available = el.querySelector('[target-id*=transcript][visibility*=HIDDEN]') || el.querySelector('[target-id*=transcript]').clientHeight; + if (available) { + const descriptionTranscript = el.querySelector('ytd-video-description-transcript-section-renderer button[aria-label]'); + descriptionTranscript ? descriptionTranscript.click() : el.querySelector('[target-id*=transcript]')?.removeAttribute('visibility'); + } +}; /*---------------------------------------------------------------- CHAPTERS --------------------------------------------------------------*/ ImprovedTube.chapters = function (el) { if (ImprovedTube.storage.chapters === true) { - el.querySelector('*[target-id*=chapters]')?.removeAttribute('visibility');} } + const available = el.querySelector('[target-id*=chapters][visibility*=HIDDEN]') || el.querySelector('[target-id*=chapters]').clientHeight; + if (available) { + const modernChapters = el.querySelector('[modern-chapters] #navigation-button button[aria-label]'); + modernChapters ? modernChapters.click() : el.querySelector('[target-id*=chapters]')?.removeAttribute('visibility'); + } +}; /*------------------------------------------------------------------------------ LIVECHAT ------------------------------------------------------------------------------*/ diff --git a/js&css/web-accessible/www.youtube.com/shortcuts.js b/js&css/web-accessible/www.youtube.com/shortcuts.js index d57d6d5fa..266d13ac0 100644 --- a/js&css/web-accessible/www.youtube.com/shortcuts.js +++ b/js&css/web-accessible/www.youtube.com/shortcuts.js @@ -403,7 +403,7 @@ ImprovedTube.shortcutChapters = function () { visibilityButton ? visibilityButton.click() : document.querySelector('*[target-id*=chapters] #visibility-button button')?.click(); } if (!modernChapters && visibilityButton) { - console.error('shortcutChapters: Cant fint proper Enble button, falling back to unreliable bruteforce method'); + console.error('shortcutChapters: Cant fint proper Enable button, falling back to unreliable bruteforce method'); } }; /*------Transcript------*/