Created
January 3, 2019 04:33
-
-
Save xioustic/9035cb045744f5e831c348f1db23be51 to your computer and use it in GitHub Desktop.
This file contains 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
// this script is meant to be pasted into a MyAnimeList Anime page console | |
// it will accumulate the total number of recommendations for each recommendation | |
// it will copy this to clipboard to be pasted into another page | |
// then paste the script again to accumulate that page's recommendations | |
// and so on... | |
if (typeof totals === 'undefined') totals = {} | |
Array.from(document.querySelectorAll('.fs10')) | |
.map(i=>i.parentNode) | |
.map(e => { | |
return { | |
title: e.querySelector('.fs10').textContent, | |
users: parseInt(e.querySelector('.users').textContent.split(' ')[0], 10) | |
} | |
}) | |
.reduce((p,c) => { | |
p[c.title] = (p[c.title] || 0) + c.users | |
return p | |
}, totals) | |
console.log(totals) | |
copy('totals = '+JSON.stringify(totals)) | |
Object.keys(totals).map(k => { return { users: totals[k], title: k } }).sort((a,b) => b.users-a.users) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment