diff --git a/js&css/web-accessible/functions.js b/js&css/web-accessible/functions.js index 60d6ce8a0..f0cb8aef0 100644 --- a/js&css/web-accessible/functions.js +++ b/js&css/web-accessible/functions.js @@ -439,9 +439,9 @@ ImprovedTube.playerOnPause = function (event) { }; if (document.documentElement.dataset.pageType === 'video' - && (ImprovedTube.storage.description === "expanded" || ImprovedTube.storage.transcript || ImprovedTube.storage.chapters)) { - ImprovedTube.forbidFocus = function (ms) { - const originalFocus = HTMLElement.prototype.focus; // Backing up default method - other methods: Element.prototype.scrollIntoView window.scrollTo window.scrollBy + && (ImprovedTube.storage.description === "expanded" || ImprovedTube.storage.transcript === true || ImprovedTube.storage.chapters === true )) { + ImprovedTube.forbidFocus = function (ms) { + originalFocus = HTMLElement.prototype.focus; // Backing up default method - other methods: Element.prototype.scrollIntoView window.scrollTo window.scrollBy // Override YouTube's scroll method: HTMLElement.prototype.focus = function () { console.log("Preventing YouTube's scripted scrolling, when expanding the video description for you"); } if (document.hidden) ms = 3 * ms; diff --git a/js&css/web-accessible/www.youtube.com/shortcuts.js b/js&css/web-accessible/www.youtube.com/shortcuts.js index c1cc450d4..eb4254a8b 100644 --- a/js&css/web-accessible/www.youtube.com/shortcuts.js +++ b/js&css/web-accessible/www.youtube.com/shortcuts.js @@ -374,7 +374,8 @@ ImprovedTube.shortcutResetPlaybackSpeed = function () { 4.7.19 GO TO SEARCH BOX ------------------------------------------------------------------------------*/ ImprovedTube.shortcutGoToSearchBox = function () { - document.querySelector('input#search')?.focus(); + if (originalFocus) { HTMLElement.prototype.focus = originalFocus } + document.querySelector('input#search')?.focus(); //alternatively .click() }; /*------------------------------------------------------------------------------ 4.7.20 ACTIVATE FULLSCREEN