|
@@ -103,6 +103,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
|
|
width: width / zoomFactor,
|
|
width: width / zoomFactor,
|
|
height: height / zoomFactor,
|
|
height: height / zoomFactor,
|
|
})
|
|
})
|
|
|
|
+ .then(() => page.route('*:\/\/video.twimg.com\/**', route => { route.abort(); }))
|
|
.then(() => page.goto(url, {waitUntil: 'load', timeout: getTimeout()}))
|
|
.then(() => page.goto(url, {waitUntil: 'load', timeout: getTimeout()}))
|
|
// hide header, "more options" button, like and retweet count
|
|
// hide header, "more options" button, like and retweet count
|
|
.then(() => page.addStyleTag({
|
|
.then(() => page.addStyleTag({
|
|
@@ -116,7 +117,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
|
|
.then(() => page.evaluate(() => {
|
|
.then(() => page.evaluate(() => {
|
|
const poll = setInterval(() => {
|
|
const poll = setInterval(() => {
|
|
document.querySelectorAll('div[data-testid="placementTracking"]').forEach(container => {
|
|
document.querySelectorAll('div[data-testid="placementTracking"]').forEach(container => {
|
|
- if (container) {
|
|
|
|
|
|
+ if (container.querySelector('div[role="button"] svg')) {
|
|
container.innerHTML = container.innerHTML;
|
|
container.innerHTML = container.innerHTML;
|
|
clearInterval(poll);
|
|
clearInterval(poll);
|
|
}
|
|
}
|
|
@@ -135,7 +136,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
|
|
.then(() => handle)
|
|
.then(() => handle)
|
|
)
|
|
)
|
|
// throw early if tweet is unavailable
|
|
// throw early if tweet is unavailable
|
|
- .then(handle => handle.$('xpath=.//a[contains(@href,"notices-on-twitter")]').then(placeholder => placeholder ? null : handle))
|
|
|
|
|
|
+ .then(handle => handle.$('[data-testid="tweet"]').then(owner => owner ? handle : null))
|
|
.catch((err: Error): Promise<puppeteer.ElementHandle<HTMLDivElement> | null> => {
|
|
.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()} ms`);
|
|
logger.warn(`navigation timed out at ${getTimerTime()} ms`);
|