Explorar o código

really fix scrolling to top of thread

Mike L %!s(int64=3) %!d(string=hai) anos
pai
achega
c28618f2a0
Modificáronse 2 ficheiros con 3 adicións e 1 borrados
  1. 1 0
      dist/webshot.js
  2. 2 1
      src/webshot.ts

+ 1 - 0
dist/webshot.js

@@ -123,6 +123,7 @@ class Webshot extends CallableInstance {
                                     continue;
                                 return document.documentElement.scrollTop = window.scrollY + div.getBoundingClientRect().top;
                             }
+                            document.documentElement.scrollTop = 0;
                         });
                     })
                         .then(() => page.evaluate(() => {

+ 2 - 1
src/webshot.ts

@@ -138,7 +138,7 @@ 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 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 => {
@@ -150,6 +150,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
                   if (getProfileUrl() !== ownerProfileUrl) continue;
                   return document.documentElement.scrollTop = window.scrollY + div.getBoundingClientRect().top;
                 }
+                document.documentElement.scrollTop = 0;
               });
             })
             .then(() => page.evaluate(() => {