|
@@ -112,7 +112,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
|
|
|
// hide header, "more options" button, like and retweet count
|
|
|
.then(() => page.addStyleTag({
|
|
|
content: 'header,#layers{display:none!important}article{background-color:transparent!important}' +
|
|
|
- '[data-testid="caret"],[role="group"],[data-testid="tweet"]+*>[class*=" "]+div:nth-last-child(2){display:none}',
|
|
|
+ '[data-testid="caret"],[role="group"],[data-testid="tweet"] [class*=" "]+:last-child>*+[class*=" "]~div{display:none}',
|
|
|
}))
|
|
|
.then(() => page.addStyleTag({
|
|
|
content: '*{font-family:-apple-system,".Helvetica Neue DeskInterface",Hiragino Sans,Hiragino Sans GB,sans-serif!important}',
|
|
@@ -129,7 +129,10 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
|
|
|
}, 250);
|
|
|
}))
|
|
|
// find main tweet
|
|
|
- .then(() => page.waitForSelector('xpath=//section/*/*/div[.//article[not(.//*[@data-testid]//time)]]', {timeout: getTimeout()}))
|
|
|
+ .then(() => page.waitForSelector(
|
|
|
+ 'xpath=//section/*/*/div[.//article[not(.//time[not(ancestor::div[@aria-labelledby])])]]',
|
|
|
+ {timeout: getTimeout()}
|
|
|
+ ))
|
|
|
// toggle visibility of sensitive tweets
|
|
|
.then(handle => handle.$$('xpath=..//a[contains(@href,"content_you_see")]/../../..//*[@role="button"]')
|
|
|
.then(sensitiveToggles => {
|
|
@@ -146,12 +149,12 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
|
|
|
logger.warn(`navigation timed out at ${getTimerTime()} seconds`);
|
|
|
return null;
|
|
|
})
|
|
|
- // scroll to last tweet by owner in thread, if any, or top of thread
|
|
|
+ // scroll to 2nd last tweet by owner in thread, if any, or top of thread
|
|
|
.then((handle: puppeteer.ElementHandle<HTMLDivElement>) => {
|
|
|
if (handle === null) throw new puppeteer.errors.TimeoutError();
|
|
|
return handle.evaluate(div => {
|
|
|
try {
|
|
|
- const selector = '[data-testid="tweet"]>:nth-child(2)>:first-child a';
|
|
|
+ const selector = '[data-testid="tweet"] :nth-child(2)>:first-child a';
|
|
|
const getProfileUrl = () => (div.querySelector<HTMLAnchorElement>(selector) || {href: ''}).href;
|
|
|
const ownerProfileUrl = getProfileUrl();
|
|
|
// eslint-disable-next-line no-cond-assign
|