Created
March 2, 2025 07:13
-
-
Save FreePhoenix888/05369b6cf353140d07c42e8d1d2db5b3 to your computer and use it in GitHub Desktop.
Sourceforge Files - Get sorted name and downloads from
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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