Преглед на файлове

attempt to retry on script loading error

Mike L преди 3 години
родител
ревизия
ca618bf047
променени са 2 файла, в които са добавени 8 реда и са изтрити 0 реда
  1. 4 0
      dist/webshot.js
  2. 4 0
      src/webshot.ts

+ 4 - 0
dist/webshot.js

@@ -80,6 +80,10 @@ class Webshot extends CallableInstance {
                     })
                         .then(() => page.route('*:\/\/video.twimg.com\/**', route => { route.abort(); }))
                         .then(() => page.goto(url, { waitUntil: 'load', timeout: getTimeout() }))
+                        .then(() => Promise.race([
+                        page.waitForSelector('article'),
+                        page.click('#placeholder+#ScriptLoadFailure input[value="Try again"]', { timeout: getTimeout() }),
+                    ]))
                         .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}',

+ 4 - 0
src/webshot.ts

@@ -105,6 +105,10 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
           })
             .then(() => page.route('*:\/\/video.twimg.com\/**', route => { route.abort(); }))
             .then(() => page.goto(url, {waitUntil: 'load', timeout: getTimeout()}))
+            .then(() => Promise.race([
+              page.waitForSelector('article'),
+              page.click('#placeholder+#ScriptLoadFailure input[value="Try again"]', {timeout: getTimeout()}),
+            ]))
             // hide header, "more options" button, like and retweet count
             .then(() => page.addStyleTag({
               content: 'header,#layers{display:none!important}article{background-color:transparent!important}' +