From 710d9d49c2f58de2787b813be3987636a9a8a368 Mon Sep 17 00:00:00 2001 From: onezplpl Date: Fri, 2 Aug 2024 21:00:24 -0400 Subject: [PATCH] attempt to extrapolate what the extra remixes are --- js/app.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/js/app.js b/js/app.js index 533889e..8582baf 100644 --- a/js/app.js +++ b/js/app.js @@ -2,11 +2,8 @@ let area = document.querySelector('#area-main'); let entries = []; let users = {}; -let fetchData; - -async function genTree(treeId, tree2) { - fetchData = fetchData || await fetch(`https://scratch.mit.edu/projects/${tree2}/remixtree/bare/`) - .then(x => x.json()); +let fetchData; +async function genTree(treeId) { entries.push(treeId) let entry = fetchData[treeId]; @@ -27,9 +24,18 @@ async function genTree(treeId, tree2) { let doThings = false; async function main() { + fetchData = await fetch(`https://scratch.mit.edu/projects/1052168454/remixtree/bare/`).then(x => x.json()); + let latestData = await fetch("https://corsproxy.io/?https://api.scratch.mit.edu/studios/34493018/projects").then(x => x.json()); - await genTree(latestData[0].id, "1052168454"); // latest project - await genTree("654605857", "1052168454"); // tree bug here, unavoidable without jank + + let lid = latestData[0].id; + while (fetchData[lid].children.length > 0) { + let ch = fetchData[lid].children; + let ch2 = ch.filter(x => fetchData[x].children.length > 0); + lid = ch2[0] || ch[0]; + } + await genTree(lid); // latest project + await genTree("654605857"); // tree bug here, unavoidable without jank doThings = true; document.querySelector('.contributors').innerHTML = Object.keys(users) .sort((x, y) => users[y] - users[x])