const link = document.createElement('a');
document.body.appendChild(link);
//Promiseを返却して処理を止める
function pause() {
return new Promise(
(resolve, reject) => {
setTimeout(resolve, 1000);
}
);
}
const files = [
"file1",
"file2",
"file3",
"file4",
"file5",
"file6",
"file7",
"file8",
"file9",
"file10",
"file11",
"file12",
"file13",
]
async function downloadAll(elements) {
var count = 0;
for (var file in files) {
link.download = `${file}.txt`;
link.href = URL.createObjectURL(link);
link.click();
URL.revokeObjectURL(link.href)
if (++count >= 10) {
await pause(1000);
count = 0;
}
}
//参考URL
https://stackoverflow.com/questions/53560991/automatic-file-downloads-limited-to-10-files-on-chrome-browser