-
-
Save msikma/d09106974bde0af113fb647af837049c 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
// 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