Skip to content

Commit

Permalink
Merge pull request #50 from HuiiBuh/features
Browse files Browse the repository at this point in the history
Fixed download all bug
  • Loading branch information
HuiiBuh authored Jul 17, 2019
2 parents b4b0c5c + a0fd4c7 commit 7e51f8b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 8 additions & 1 deletion chrome/js/downloadAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const dlAllImage = "v1Nh3 kIKUG _bz0w";
const dlAllLoader = "By4nA";
const dlAllStopClass = "_0mzm- sqdOP yWX7d";

let visited = false;

class DownloadAll {
/**
Expand Down Expand Up @@ -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);
Expand All @@ -151,14 +155,17 @@ class DownloadAll {

let dlUrl = this.createDownloadImages();
chrome.runtime.sendMessage({"url": dlUrl, "user": "HuiBuh", "type": "bulk"});

visited = false;
}

/**
* Scrolls down until all images are collected and takes the links to the images
*/
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;
Expand Down
11 changes: 10 additions & 1 deletion firefox/js/downloadAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const dlAllImage = "v1Nh3 kIKUG _bz0w";
const dlAllLoader = "By4nA";
const dlAllStopClass = "_0mzm- sqdOP yWX7d";

let visited = false;


class DownloadAll {
/**
Expand Down Expand Up @@ -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);
Expand All @@ -151,14 +156,18 @@ class DownloadAll {

let dlUrl = this.createDownloadImages();
browser.runtime.sendMessage({"url": dlUrl, "user": "HuiBuh", "type": "bulk"});

visited = false;
}

/**
* Scrolls down until all images are collected and takes the links to the images
*/
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;
Expand Down

0 comments on commit 7e51f8b

Please sign in to comment.