Skip to content

Instantly share code, notes, and snippets.

@djyde
Created January 21, 2023 04:15
Show Gist options
  • Save djyde/32fd10fe32a71e49a44737f6515e605a to your computer and use it in GitHub Desktop.
Save djyde/32fd10fe32a71e49a44737f6515e605a to your computer and use it in GitHub Desktop.
Readwise scripts
async function getBooks(category) {
return await (await fetch(`/api/books/?category=${category}`)).json()
}
async function deleteBook(id) {
return await (await fetch(`/api/user_delete_book`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-CSRFToken': Cookies.get('csrftoken')
},
body: new URLSearchParams({
userBookId: id,
isPermanent: 'true'
})
})).json()
}
async function run() {
const books = await getBooks('tweets')
for (const book of books) {
console.log('deleteing', book.id)
await deleteBook(book.id)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment