(async () => { year=2023 username = 'hikaru' for(var month=1; month<=12; month++) { let url = `https://api.chess.com/pub/player/${username}/games/${year}/${month}/pgn` response = await fetch(url) const bodyText = await response.text(); const blob = new Blob([bodyText], { type: 'text/plain' }); const a = document.createElement('a'); a.style.display = 'none'; document.body.appendChild(a); url = window.URL.createObjectURL(blob); a.href = url; const monthFormatted = month < 10 ? `0${month}` : month; a.download = `ChessCom_${username}_${year}${monthFormatted}.pgn`; a.click(); window.URL.revokeObjectURL(url); document.body.removeChild(a); } })()