mid 2024 UI update

This commit is contained in:
onezplpl 2024-08-02 03:42:44 -04:00
parent 95b1fe3fe5
commit e31345b503
No known key found for this signature in database
GPG key ID: 7EC026A136F9EEC3
4 changed files with 71 additions and 41 deletions

View file

@ -5,8 +5,8 @@ let users = {};
let fetchData;
async function genTree(treeId) {
fetchData = fetchData || await fetch(`https://scratch.mit.edu/projects/${treeId}/remixtree/bare/`)
.then(x => x.json());
fetchData = fetchData || await fetch(`https://scratch.mit.edu/projects/${treeId}/remixtree/bare/`)
.then(x => x.json());
entries.push(treeId)
let entry = fetchData[treeId];
@ -14,8 +14,11 @@ async function genTree(treeId) {
while (entry) {
entry = entry.parent_id;
entries.push(entry);
entry = fetchData[entry];
if (entry) users[entry.username] = true;
let entryDat = fetchData[entry];
if (!entryDat) continue;
let us = users[entryDat.username];
users[entryDat.username] = (us ? us : 0) + 1 / entries.length;
entry = entryDat;
}
return entry;
@ -24,11 +27,14 @@ async function genTree(treeId) {
let doThings = false;
async function main() {
let latestData = await fetch("https://trampoline.turbowarp.org/proxy/studios/34493018/projects").then(x => x.json());
let latestData = await fetch("https://trampoline.turbowarp.org/proxy/studios/34493018/projects").then(x => x.json());
await genTree(latestData[0].id); // latest project
await genTree("654605857"); // tree bug here, unavoidable without jank
doThings = true;
document.querySelector('.contributors').textContent = Object.keys(users).join(', ');
document.querySelector('.contributors').innerHTML = Object.keys(users)
.sort((x, y) => users[y] - users[x])
.map(x => `<a href='https://scratch.mit.edu/users/${x}'>${x}</a> <sub>${Math.trunc(users[x] / Math.log(entries.length) * 100000) / 1000}%</sub>`)
.join(', '); // Doesn't need to be sanitized (hopefully)
}
main();
@ -41,15 +47,15 @@ function sanitize(content) {
return decoder.innerHTML;
}
setInterval(function() {
setInterval(function () {
if (doThings && (window.innerHeight + window.scrollY) >= document.body.scrollHeight - 25) {
let h = '';
let h = '';
for (let j = 0; j < 35; j++) {
let entry = entries[i];
if (!entry || !(entry in fetchData)) break;
h += `<div class='proj'><a href="https://scratch.mit.edu/projects/${entry}"><img src='https://uploads.scratch.mit.edu/get_image/project/${entry}_1920x1080.png'>${sanitize(fetchData[entry].title)} [${entries.length - i }]</a></div>`;
h += `<div class='proj'><a href="https://scratch.mit.edu/projects/${entry}"><img src='https://uploads.scratch.mit.edu/get_image/project/${entry}_1920x1080.png'>${sanitize(fetchData[entry].title)}</a> <sub>#${entries.length - i} by ${fetchData[entry].username}</sub></div>`;
i++;
}
area.innerHTML += h;
}
},500);
}, 500);