Last active
February 24, 2025 13:51
-
-
Save danmactough/24decd20feeafb1d1f021385bceb832b to your computer and use it in GitHub Desktop.
Download all your Kindle books before Feb 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Log in to your Amazon account | |
// 2. Go to your Content Library > Books - https://www.amazon.com/hz/mycd/digital-console/contentlist/booksAll/dateDsc/ | |
// 3. Open your browser's Javascript console | |
// 4. For each page of books, paste this script into the console | |
function closeNotification() { | |
document.querySelector('span#notification-close').click(); | |
} | |
function pause(duration = 1000) { | |
return new Promise((resolve) => { | |
setTimeout(resolve, duration); | |
}); | |
} | |
menus = Array.from( | |
document.querySelectorAll('div[id*="DOWNLOAD_AND_TRANSFER_ACTION_"]') | |
).filter((el) => !el.id.endsWith('CONFIRM') && !el.id.endsWith('CANCEL')); | |
inputs = Array.from( | |
document.querySelectorAll( | |
// If you have multiple Kindles, I think you're going to need to tweak this selector or add a filter like the menus selector | |
// to restrict your result to just the one Kindle that you are targeting | |
"ul[id^='download_and_transfer_list_'] > li[class^='ActionList-module_action_list_item__'] > div > label" | |
) | |
); | |
buttons = Array.from( | |
document.querySelectorAll( | |
"div[id^='DOWNLOAD_AND_TRANSFER_DIALOG_'] div[class^='DeviceDialogBox-module_button_container__'] > div[id$='_CONFIRM']" | |
) | |
); | |
(async function () { | |
for (let i = 0; i < 25; i++) { | |
if (menus[i]) { | |
menus[i].click(); | |
inputs[i].click(); | |
buttons[i].click(); | |
await pause(); | |
closeNotification(); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment