add scripts
This commit is contained in:
parent
11e325d25e
commit
51699134bc
2 changed files with 68 additions and 0 deletions
37
download.js
Normal file
37
download.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
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)
|
31
download_tree.js
Normal file
31
download_tree.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
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)
|
Loading…
Reference in a new issue