Last active
April 29, 2024 07:21
-
-
Save hushin/27129d616552648d97f972deded54a25 to your computer and use it in GitHub Desktop.
This file contains 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
;(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