Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#65: Fix "make picks" when previous games have been played #66

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading