Преглед изворни кода

change detection for deleted tweets

Mike L пре 3 година
родитељ
комит
a065b647ca
2 измењених фајлова са 2 додато и 2 уклоњено
  1. 1 1
      dist/webshot.js
  2. 1 1
      src/webshot.ts

+ 1 - 1
dist/webshot.js

@@ -106,7 +106,7 @@ class Webshot extends CallableInstance {
                         return utils_1.chainPromises(sensitiveToggles.filter(toggle => toggle.isVisible()).map(toggle => () => toggle.click()));
                     })
                         .then(() => handle))
-                        .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) => {
                         if (err.name !== 'TimeoutError')
                             throw err;

+ 1 - 1
src/webshot.ts

@@ -136,7 +136,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
               .then(() => handle)
             )
             // 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> => {
               if (err.name !== 'TimeoutError') throw err;
               logger.warn(`navigation timed out at ${getTimerTime()} seconds`);