From 408bc5cf52730f1529d33e420e8f3676a474c89b Mon Sep 17 00:00:00 2001 From: Brock Chelle Date: Sat, 9 Sep 2023 11:17:29 -0600 Subject: [PATCH] #65: Fix "make picks" when previous games have been played (#66) --- src/utils/game.ts | 2 +- src/webscraper/init.ts | 3 +-- src/webscraper/makePicks.ts | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils/game.ts b/src/utils/game.ts index f951daa..34e01b0 100644 --- a/src/utils/game.ts +++ b/src/utils/game.ts @@ -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}`) } diff --git a/src/webscraper/init.ts b/src/webscraper/init.ts index fea9ece..eb9bf80 100644 --- a/src/webscraper/init.ts +++ b/src/webscraper/init.ts @@ -14,8 +14,7 @@ export const initBrowser = async (): Promise => { ? [`--proxy-server=${env.proxy.host}`] : [], ignoreHTTPSErrors: true, - headless: env.browser.headless, - devtools: true + headless: env.browser.headless }) } diff --git a/src/webscraper/makePicks.ts b/src/webscraper/makePicks.ts index 6a9b8c2..57ebca6 100644 --- a/src/webscraper/makePicks.ts +++ b/src/webscraper/makePicks.ts @@ -55,7 +55,7 @@ const getPickButtons = async (page: Page): Promise => { * @returns An array of size n, where n is the number of games */ const getRankPickers = async (page: Page): Promise => { - const rankPickerSelector = '.row.gamerow input.hrank' + const rankPickerSelector = '.row.gamerow input.hrank, .row.gamerow button.rankResult' await page.waitForSelector(rankPickerSelector) return await page.$$(rankPickerSelector) @@ -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()) }