37 lines
No EOL
981 B
JavaScript
37 lines
No EOL
981 B
JavaScript
var tree = [], gek, the;
|
|
|
|
function downloadURI(uri, name) {
|
|
var link = document.createElement("a");
|
|
link.download = name;
|
|
link.href = uri;
|
|
link.click();
|
|
}
|
|
|
|
async function downloadUser(user = "08draven") {
|
|
let i = 0;
|
|
for (let i = 0; ; i++) {
|
|
let fetchReq = await fetch(`https://api.scratch.mit.edu/users/${user}/projects/?limit=40&offset=${i * 40}`);
|
|
let fetchJson = await fetchReq.json();
|
|
if (fetchJson.length < 1) break;
|
|
tree = [...tree, ...fetchJson];
|
|
}
|
|
gek = 0;
|
|
}
|
|
|
|
async function getPoject() {
|
|
if (the = tree[gek]) {
|
|
the = the.id;
|
|
e = await fetch("https://api.scratch.mit.edu/projects/" + the);
|
|
e = await e.json();
|
|
if (e.project_token != undefined) {
|
|
downloadURI("https://projects.scratch.mit.edu/" + the + "?token=" + e.project_token, the)
|
|
}
|
|
gek++;
|
|
} else {
|
|
console.log("end");
|
|
}
|
|
}
|
|
|
|
await downloadUser();
|
|
|
|
setInterval(getPoject, 500) |