Last active
November 20, 2023 20:40
-
-
Save Kagee/aa39c1e98a10d9e0909faf8323db7f87 to your computer and use it in GitHub Desktop.
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
// Get amazon book list as JSON data | |
// Based on https://gist.github.com/yige233/274fbd29ba26a6f9d75d698c1790e0d5 | |
// 1 open i.e. https://www.amazon.com/hz/mycd/digital-console/contentlist/booksAll/dateDsc/ | |
// 2. Open developer console | |
// 4. If required, adapt the fetch url below. | |
// 5. If required ajust batchSize | |
// 6. paste into developer console and press enter | |
// 7. Promise {<Pending>} will appear | |
// 8. AFter a while a js structure starting with {success: true, .... should appear. | |
// 9. Right click that line, "Copy object" | |
// 10. Paste the "object" into a editor, and prosess it as JSON with fitting tools. | |
// Examples: | |
// jq -r '(.GetContentOwnershipData.items | map([.title, .authors]))[] | join("; ")' amazon-kindle.json | |
// jq -r '(.GetContentOwnershipData.items | map([.title, .authors]))[] | @csv' amazon-kindle.json | |
ownershipDataEbook = { | |
contentType: "Ebook", | |
contentCategoryReference: "booksAll", | |
itemStatusList: ["Active"], | |
excludeExpiredItemsFor: ["KOLL", "Purchase", "Pottermore", "FreeTrial", "DeviceRegistration", "KindleUnlimited", "Sample", "Prime", "ComicsUnlimited", "Comixology"], | |
originTypes: ["Purchase", "PublicLibraryLending", "PersonalLending", "Sample", "ComicsUnlimited", "KOLL", "RFFLending", "Pottermore", "Prime", "Rental", "DeviceRegistration", "FreeTrial", "KindleUnlimited", "Comixology"], | |
}, | |
ownershipDataCommon = { | |
showSharedContent: true, | |
fetchCriteria: { sortOrder: "DESCENDING", sortIndex: "DATE", startIndex: 0, batchSize: 500, totalContentCount: -1 }, | |
surfaceType: "LargeDesktop", | |
} | |
fetch("https://www.amazon.com/hz/mycd/digital-console/ajax", { | |
headers: { | |
"content-type": "application/x-www-form-urlencoded", | |
}, | |
method: "POST", | |
body: [["activity", 'GetContentOwnershipData'].join("="), ["activityInput", JSON.stringify(Object.assign({}, ownershipDataCommon, ownershipDataEbook))].join("="), ["csrfToken", encodeURIComponent(window.csrfToken)].join("=")].join("&"), | |
credentials: "include", | |
}).then(res => res.json()) | |
.then(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment