Skip to content

Commit

Permalink
#65: Fix "make picks" when previous games have been played (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
blchelle authored Sep 9, 2023
1 parent 37ad8d8 commit 408bc5c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/utils/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const mergeOfpAndOddsData = (ofpGames: OfpData, oddsGames: OddsData): Gam
ofpTeamToOddsApiTeam(home.team) === game.home_team.toLowerCase()
))

if (matchingGame == null) {
if (matchingGame === undefined) {
throw new Error(`could not find a matching game for ${away.team} at ${home.team}`)
}

Expand Down
3 changes: 1 addition & 2 deletions src/webscraper/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export const initBrowser = async (): Promise<Browser | undefined> => {
? [`--proxy-server=${env.proxy.host}`]
: [],
ignoreHTTPSErrors: true,
headless: env.browser.headless,
devtools: true
headless: env.browser.headless
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/webscraper/makePicks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const getPickButtons = async (page: Page): Promise<ElementHandle[][]> => {
* @returns An array of size n, where n is the number of games
*/
const getRankPickers = async (page: Page): Promise<ElementHandle[]> => {
const rankPickerSelector = '.row.gamerow input.hrank'
const rankPickerSelector = '.row.gamerow input.hrank, .row.gamerow button.rankResult'

await page.waitForSelector(rankPickerSelector)
return await page.$$(rankPickerSelector)
Expand All @@ -79,7 +79,7 @@ const pickGame = async (page: Page, gameInputs: GameInputs, pick: Pick): Promise
// Only click the button if it hasn't been previously selected from a prior session
if (!await elementHandleHasClass(buttons[teamPicked], 'btn-pickable-saved')) await simulateClick(buttons[teamPicked], 'Space')

// Clicking the rank picker will show a dropdown
// Manually updates the value of the rank picker
const rankPickerID = await (await rankPicker.getProperty('id')).jsonValue()
await page.$eval(`#${rankPickerID}`, (el, rank) => { el.setAttribute('value', rank.toString()) }, rank.toString())
}
Expand Down

0 comments on commit 408bc5c

Please sign in to comment.