Untitled
unknown
javascript
2 years ago
702 B
8
Indexable
const rows = document.querySelectorAll('tr');
const userCounts = {};
rows.forEach(row => {
const usernameElement = row.querySelector('.tabletd:nth-child(2) div:first-child');
const countElement = row.querySelector('.tabletd:nth-child(5) div:first-child');
if (usernameElement && countElement) {
const username = usernameElement.textContent.trim();
const count = countElement.textContent.trim();
if (username && count) {
userCounts[username] = (userCounts[username] || 0) + parseInt(count, 10);
}
}
});
for (const username in userCounts) {
if (userCounts.hasOwnProperty(username)) {
console.log(`${username} ${userCounts[username]}`);
}
}Editor is loading...
Leave a Comment