Skip to content

Instantly share code, notes, and snippets.

@hushin
Last active April 29, 2024 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hushin/27129d616552648d97f972deded54a25 to your computer and use it in GitHub Desktop.
Save hushin/27129d616552648d97f972deded54a25 to your computer and use it in GitHub Desktop.
;(async (copy) => {
// https://read.amazon.co.jp/kindle-library を開いて実行
// ASINコードがクリップボードにコピーされているので
// https://booklog.jp/input に貼り付けて登録
async function fetchList(paginationToken) {
const pagination = paginationToken
? `&paginationToken=${paginationToken}`
: ''
const res = await fetch(
`https://read.amazon.co.jp/kindle-library/search?query=&libraryType=BOOKS&sortType=recency&querySize=50${pagination}`,
)
return res.json()
}
const fetchTimes = 2 // 差分だけ取りたいので適当なページ数取る
const tsvData = []
let currentPaginationToken
for (let index = 0; index < fetchTimes; index++) {
const data = await fetchList(currentPaginationToken)
const { itemsList, paginationToken } = data
currentPaginationToken = paginationToken
itemsList.forEach((item) => {
tsvData.push([item.asin])
})
}
const tsv = tsvData.join('\n')
console.log(tsv)
copy(tsv)
})(copy)
// ref. https://gist.github.com/usayamadx/9c638d9b70bc714d6dd6043fcd54085f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment