|
@@ -132,8 +132,14 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
|
|
|
.then((handle: puppeteer.ElementHandle<HTMLDivElement>) => {
|
|
|
if (handle === null) throw new puppeteer.errors.TimeoutError();
|
|
|
return handle.evaluate(div => {
|
|
|
- const replyingTo = div.previousElementSibling;
|
|
|
- if (replyingTo) document.documentElement.scrollTop = window.scrollY + replyingTo.getBoundingClientRect().top;
|
|
|
+ const selector = '[data-testid="tweet"]>:nth-child(2)>:first-child a';
|
|
|
+ const getProfileUrl = () => div.querySelector<HTMLAnchorElement>(selector).href;
|
|
|
+ const ownerProfileUrl = getProfileUrl();
|
|
|
+ // eslint-disable-next-line no-cond-assign
|
|
|
+ while (div = div.previousElementSibling as HTMLDivElement) {
|
|
|
+ if (getProfileUrl() !== ownerProfileUrl) continue;
|
|
|
+ return document.documentElement.scrollTop = window.scrollY + div.getBoundingClientRect().top;
|
|
|
+ }
|
|
|
});
|
|
|
})
|
|
|
.then(() => page.evaluate(() => {
|