Skip to content

Instantly share code, notes, and snippets.

@msikma
Last active October 3, 2021 23:02
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 msikma/d09106974bde0af113fb647af837049c to your computer and use it in GitHub Desktop.
Save msikma/d09106974bde0af113fb647af837049c to your computer and use it in GitHub Desktop.
// Note: gets number of matches played as yokozuna on a rikishi's page,
// e.g. http://sumodb.sumogames.de/Rikishi.aspx?r=1123.
// Does not count fusenpai.
console.log([...document.querySelectorAll('.rikishi tr')].flatMap(tr => {
const tds = tr.querySelectorAll('td')
if (tds.length === 0) return 0
const rank = tds[1].innerText.trim()
if (!rank.startsWith('Y')) return 0
const hoshi = [...tds[2].querySelectorAll('img')].map(img => {
const src = img.getAttribute('src')
// Only matches that were actually played, since they include dohyo-iri.
if (src.includes('hoshi_shiro') || src.includes('hoshi_kuro') || src.includes('hoshi_fusensho')) {
return 1
}
return 0
})
return hoshi
}).reduce((n, item) => n + item, 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment