From 6ab597924eecdd8be02f159826157f869b234896 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Mon, 8 Feb 2021 19:13:07 +0100 Subject: [PATCH] #161 Improved query to find first unseen episode --- src/javascript/enhancements/watch2getherAutoscroll.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/javascript/enhancements/watch2getherAutoscroll.ts b/src/javascript/enhancements/watch2getherAutoscroll.ts index e0e44f6..0f0ba36 100644 --- a/src/javascript/enhancements/watch2getherAutoscroll.ts +++ b/src/javascript/enhancements/watch2getherAutoscroll.ts @@ -18,8 +18,10 @@ export function init(): void { function observeSearchResults(searchRes: Element): void { let observer = new MutationObserver(mutations => { mutations.forEach(mutation => { - let num = searchRes.getElementsByClassName('md-2-line border _md-button-wrap _md md-clickable animelist-completed').length; - scrollTo(searchRes, num); + let scrollTarget = searchRes.querySelector('.ep-view md-list-item:not(.animelist-completed)'); + if (assigned(scrollTarget)) { + scrollTarget.scrollIntoView(); + } }); });