Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions download-all-kindle-books.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
// Get all dropdowns with the class prefix 'Dropdown-module_container__'
const dropdowns = document.querySelectorAll('[class^="Dropdown-module_container__"]');

let skipped = 0;
for (let i = 0; i < dropdowns.length; i++) {
// Open the dropdown
const dropdown = dropdowns[i];
Expand All @@ -64,6 +65,15 @@
// Wait a moment for the dropdown to open and perform the actions
await new Promise(resolve => setTimeout(resolve, 500));

// Has download link
let tempDiv = Array.from(dropdown.querySelector('[class^="Dropdown-module_dropdown_container__"]').querySelectorAll('div'))
.find(div => div.textContent.includes('Download & transfer via USB')); // Download & transfer via USB
let hasDownload = typeof tempDiv == 'object';
if (! hasDownload) {
console.log(++skipped, 'titles skipped');
continue;
}

// Now perform the actions on the opened dropdown using wildcard selectors
await new Promise(resolve => setTimeout(() => {
const topDiv = Array.from(dropdown.querySelector('[class^="Dropdown-module_dropdown_container__"]').querySelectorAll('div'))
Expand Down