|
@@ -123,14 +123,18 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
|
|
});
|
|
});
|
|
}, 250);
|
|
}, 250);
|
|
}))
|
|
}))
|
|
- .then(() => page.waitForSelector('article', {timeout: getTimeout()}))
|
|
|
|
- .catch((err: Error): Promise<puppeteer.ElementHandle<Element> | null> => {
|
|
|
|
|
|
+ .then(() => page.waitForSelector('xpath=//section/*/*/div[.//article/*/*/*/*/*[@role="group"]]', {timeout: getTimeout()}))
|
|
|
|
+ .catch((err: Error): Promise<puppeteer.ElementHandle<HTMLDivElement> | null> => {
|
|
if (err.name !== 'TimeoutError') throw err;
|
|
if (err.name !== 'TimeoutError') throw err;
|
|
logger.warn(`navigation timed out at ${getTimerTime()} seconds`);
|
|
logger.warn(`navigation timed out at ${getTimerTime()} seconds`);
|
|
return null;
|
|
return null;
|
|
})
|
|
})
|
|
- .then(handle => {
|
|
|
|
|
|
+ .then((handle: puppeteer.ElementHandle<HTMLDivElement>) => {
|
|
if (handle === null) throw new puppeteer.errors.TimeoutError();
|
|
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;
|
|
|
|
+ });
|
|
})
|
|
})
|
|
.then(() => page.evaluate(() => {
|
|
.then(() => page.evaluate(() => {
|
|
const cardImg = document.querySelector('div[data-testid^="card.layout"][data-testid$=".media"] img');
|
|
const cardImg = document.querySelector('div[data-testid^="card.layout"][data-testid$=".media"] img');
|
|
@@ -156,9 +160,6 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
|
|
.then(cardImg => {
|
|
.then(cardImg => {
|
|
if (cardImg) this.extendEntity(cardImg);
|
|
if (cardImg) this.extendEntity(cardImg);
|
|
})
|
|
})
|
|
- .then(() => page.addScriptTag({
|
|
|
|
- content: 'document.documentElement.scrollTop=0;',
|
|
|
|
- }))
|
|
|
|
.then(() => chainPromises(morePostProcessings.map(func => () => func(page))))
|
|
.then(() => chainPromises(morePostProcessings.map(func => () => func(page))))
|
|
.then(() => promisify(setTimeout)(getTimeout()))
|
|
.then(() => promisify(setTimeout)(getTimeout()))
|
|
.then(() => page.screenshot())
|
|
.then(() => page.screenshot())
|