Skip to content

Instantly share code, notes, and snippets.

@xioustic
Created January 3, 2019 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xioustic/9035cb045744f5e831c348f1db23be51 to your computer and use it in GitHub Desktop.
Save xioustic/9035cb045744f5e831c348f1db23be51 to your computer and use it in GitHub Desktop.
// 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