let area = document.querySelector('#area-main'); let entries = []; let users = {}; let fetchData; let sum = 0; let doThings = false; let i = 0; async function genTree(treeId) { let entry = treeId; while (true) { let entryDat = fetchData[entry]; entries.push(entry); if (!entryDat) break; let us = users[entryDat.username]; let s = 1 / ((new Date() - new Date(entryDat.datetime_created.$date)) + 1000 * 60 * 60); sum += s; users[entryDat.username] = (us ? us : 0) + s; entry = entryDat.parent_id; } return entry; } async function main() { let users = document.querySelector('#users').value.split('\n'); let url = new URL(window.location); url.search = '?users=' + users.join('&users='); history.pushState(null, '', url); entries = []; for (let user of users) { let extraFetch = await fetch(`https://hf.zenoverse.net/user/${user}`, { }); extraFetch = await extraFetch.json(); extraFetch.forEach(x => x.username = user); entries = [...entries, ...extraFetch]; } entries = entries.sort((a, b) => b.id - a.id); let params = new URL(window.location).searchParams; let start = params.get('start') * 1; let end = params.get('end') * 1; end = Math.min(end, entries.length - 2); if (start && end) { entries = entries.splice(entries.length - end - 2, end - start + 1); } doThings = true; setInterval(function () { if (doThings && (window.innerHeight + window.scrollY) >= document.body.scrollHeight - 25) scroller(); }, 500); } function sanitize(content) { const decoder = document.createElement('div'); decoder.textContent = content; return decoder.innerHTML; } function scroller() { let h = ''; for (let j = 0; j < 35; j++) { let entry = entries[i]; if (!entry) continue; h += `
${entry.title} by ${entry.username}
`; i++; } area.innerHTML += h; } let sub = document.querySelector('#users'); let params = new URLSearchParams(window.location.search).getAll('users'); let val = params.join('\n') || sub.value; sub.textContent = sub.value = val; main(); document.querySelector('#submit').onclick = main;