From a0fd4c71105c33906cd6eab3ee18c1f2ffec6279 Mon Sep 17 00:00:00 2001 From: Niclas Haderer Date: Wed, 17 Jul 2019 13:37:21 +0200 Subject: [PATCH] Fixed bug in download all (this caused the downoad not to start while all images were loaded --- chrome/js/downloadAll.js | 9 ++++++++- firefox/js/downloadAll.js | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/chrome/js/downloadAll.js b/chrome/js/downloadAll.js index 512b5e4..0d8d1bf 100644 --- a/chrome/js/downloadAll.js +++ b/chrome/js/downloadAll.js @@ -3,6 +3,7 @@ const dlAllImage = "v1Nh3 kIKUG _bz0w"; const dlAllLoader = "By4nA"; const dlAllStopClass = "_0mzm- sqdOP yWX7d"; +let visited = false; class DownloadAll { /** @@ -141,6 +142,9 @@ class DownloadAll { * Start the video download */ async start() { + + alert("The download starts. Please be patient event after the scrolling."); + //scroll down and get the xhttp requests and the json await this.scrollDown(); await this.requests(this.urls); @@ -151,6 +155,8 @@ class DownloadAll { let dlUrl = this.createDownloadImages(); chrome.runtime.sendMessage({"url": dlUrl, "user": "HuiBuh", "type": "bulk"}); + + visited = false; } /** @@ -158,7 +164,8 @@ class DownloadAll { */ async scrollDown() { await sleep(10); - while (document.getElementsByClassName(dlAllLoader).length > 0) { + while (document.getElementsByClassName(dlAllLoader).length > 0 || !visited) { + visited = true; scrollBy(0, 10000); if (document.getElementsByClassName(dlAllStopClass).length > 0) return; diff --git a/firefox/js/downloadAll.js b/firefox/js/downloadAll.js index e3816db..2387f2d 100644 --- a/firefox/js/downloadAll.js +++ b/firefox/js/downloadAll.js @@ -3,6 +3,8 @@ const dlAllImage = "v1Nh3 kIKUG _bz0w"; const dlAllLoader = "By4nA"; const dlAllStopClass = "_0mzm- sqdOP yWX7d"; +let visited = false; + class DownloadAll { /** @@ -141,6 +143,9 @@ class DownloadAll { * Start the video download */ async start() { + + alert("The download starts. Please be patient event after the scrolling."); + //scroll down and get the xhttp requests and the json await this.scrollDown(); await this.requests(this.urls); @@ -151,6 +156,8 @@ class DownloadAll { let dlUrl = this.createDownloadImages(); browser.runtime.sendMessage({"url": dlUrl, "user": "HuiBuh", "type": "bulk"}); + + visited = false; } /** @@ -158,7 +165,9 @@ class DownloadAll { */ async scrollDown() { await sleep(10); - while (document.getElementsByClassName(dlAllLoader).length > 0) { + + while (document.getElementsByClassName(dlAllLoader).length > 0 || !visited) { + visited = true; scrollBy(0, 10000); if (document.getElementsByClassName(dlAllStopClass).length > 0) return;