scratch-utils/download_tree.js

31 lines
793 B
JavaScript
Raw Permalink Normal View History

2024-09-19 02:49:56 -04:00
var tree = [], gek, the;
function downloadURI(uri, name) {
var link = document.createElement("a");
link.download = name;
link.href = uri;
link.click();
}
async function downloadTree(id = "945859211") {
tree = await fetch("https://scratch.mit.edu/projects/"+id+"/remixtree/bare");
tree = await tree.json();
gek = tree.root_id;
}
async function getPoject() {
if (the != gek) {
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)
}
the = tree[the].parent_id
} else {
console.log("end");
}
}
await downloadTree();
setInterval(getPoject, 500)