Browse Source

avoid clicking invisible buttons

Mike L 3 years ago
parent
commit
c8e1bcfbeb
2 changed files with 2 additions and 2 deletions
  1. 1 1
      dist/webshot.js
  2. 1 1
      src/webshot.ts

+ 1 - 1
dist/webshot.js

@@ -102,7 +102,7 @@ class Webshot extends CallableInstance {
                         const count = sensitiveToggles.length;
                         const count = sensitiveToggles.length;
                         if (count)
                         if (count)
                             logger.info(`found ${count} sensitive ${count === 1 ? 'tweet' : 'tweets'} on page, uncollapsing...`);
                             logger.info(`found ${count} sensitive ${count === 1 ? 'tweet' : 'tweets'} on page, uncollapsing...`);
-                        return Promise.all(sensitiveToggles.map(toggle => toggle.click()));
+                        return utils_1.chainPromises(sensitiveToggles.filter(toggle => toggle.isVisible()).map(toggle => () => toggle.click()));
                     })
                     })
                         .then(() => handle))
                         .then(() => handle))
                         .catch((err) => {
                         .catch((err) => {

+ 1 - 1
src/webshot.ts

@@ -130,7 +130,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
               .then(sensitiveToggles => {
               .then(sensitiveToggles => {
                 const count = sensitiveToggles.length;
                 const count = sensitiveToggles.length;
                 if (count) logger.info(`found ${count} sensitive ${count === 1 ? 'tweet' : 'tweets'} on page, uncollapsing...`);
                 if (count) logger.info(`found ${count} sensitive ${count === 1 ? 'tweet' : 'tweets'} on page, uncollapsing...`);
-                return Promise.all(sensitiveToggles.map(toggle => toggle.click()));
+                return chainPromises(sensitiveToggles.filter(toggle => toggle.isVisible()).map(toggle => () => toggle.click()));
               })
               })
               .then(() => handle)
               .then(() => handle)
             )
             )