bskinn / bga-wingspan-scraper

Firefox extension to scrape data from a Wingspan game replay on BGA
MIT License
2 stars 0 forks source link

Scraping bonus card info mid-game #25

Open bskinn opened 11 months ago

bskinn commented 11 months ago

End-of-game bonus card info and scores for all players can be scraped from the last move of the move log.

If midgame bonus card holdings are of interest, we'll have to scrape the game from each player's view.

If midgame bonus card scores are of interest, the easiest approach is probably to scrape the mouseover text for each held bonus card (see #13):

Looks roughly like (though have to do it for each bonus card div that matches the pattern):

hand_div = $$('div[id^="handcard_bonus_panel_"][class~="wsp_bonus"]')[0]  // But loop instead
hand_div.dispatchEvent(new MouseEvent("mouseover"))
// wait 3 sec
popup_div = [...$$('div[class~="wsp_tooltip_text"]')].filter(div => div.textContent.includes('were to end now'))[0]
// scrape the score for the card
hand_div.dispatchEvent(new MouseEvent("mouseout"))

Originally posted by @bskinn in https://github.com/bskinn/bga-wingspan-scraper/issues/12#issuecomment-1732393215