await (async () => { const thread = 36933561; const response = await fetch(`https://desuarchive.org/_/api/chan/thread/?board=mlp&num=${thread}`); const data = await response.json(); const posts = [data[thread].op, ...Object.values(data[thread].posts)]; return posts .map(post => JSON.parse(post.exif)?.troll_country_name) .filter(flag => flag) .reduceRight((dict, flag, i) => { dict[flag] = (dict[flag] ?? 0) + 1; return i > 0 ? dict : Object.entries(dict); }, {}) .map(([flag, occurrences]) => ({ flag, occurrences })) .sort((a, b) => b.occurrences - a.occurrences) .map(({ flag, occurrences }, i) => `>${i + 1}. ${flag}: ${occurrences} posts`) .join("\n"); })();