Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FreePhoenix888/05369b6cf353140d07c42e8d1d2db5b3 to your computer and use it in GitHub Desktop.
Save FreePhoenix888/05369b6cf353140d07c42e8d1d2db5b3 to your computer and use it in GitHub Desktop.
Sourceforge Files - Get sorted name and downloads from
let data = [];
document.querySelectorAll("#files_list tbody tr").forEach(row => {
let name = row.querySelector("th .name")?.innerText.trim();
let downloadsText = row.querySelector(".stats .count")?.innerText.trim();
if (name && downloadsText) {
let downloads = parseInt(downloadsText.replace(/,/g, ""), 10); // Remove commas & convert to number
data.push({ name, downloads });
}
});
// Sort data by downloads (descending order)
data.sort((a, b) => b.downloads - a.downloads);
// Print sorted data
data.forEach(item => console.log(`Name: ${item.name}, Downloads: ${item.downloads}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment