From 7cfbba237ce7ac8956613a5ab4cbb6f8e58de9ee Mon Sep 17 00:00:00 2001 From: derv Date: Wed, 3 Jan 2024 09:43:38 -0500 Subject: [PATCH] cool --- js/app.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/app.js b/js/app.js index c05e232..b005cd7 100644 --- a/js/app.js +++ b/js/app.js @@ -5,7 +5,7 @@ let users = {}; let fetchData; async function genTree(treeId) { - fetchData = await fetch(`https://scratch.mit.edu/projects/${treeId}/remixtree/bare`) + fetchData = fetchData || await fetch(`https://scratch.mit.edu/projects/${treeId}/remixtree/bare/`) .then(x => x.json()); entries.push(treeId) @@ -21,10 +21,12 @@ async function genTree(treeId) { return entry; } +let doThings = false; + async function main() { - await genTree("946114669"); // latest project + await genTree("946309808"); // latest project await genTree("654605857"); // tree bug here, unavoidable without jank - console.log(entries) + doThings = true; document.querySelector('.contributors').textContent = Object.keys(users).join(', '); } @@ -39,10 +41,11 @@ function sanitize(content) { } setInterval(function() { - if ((window.innerHeight + window.scrollY) >= document.body.scrollHeight) { + if (doThings && (window.innerHeight + window.scrollY) >= document.body.scrollHeight - 25) { let h = ''; for (let j = 0; j < 35; j++) { let entry = entries[i]; + if (!entry || !(entry in fetchData)) break; h += `
${sanitize(fetchData[entry].title)} [${entries.length - i }]
`; i++; }