diff --git a/README.md b/README.md index aeaaade..e1c21b9 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Here is a list of variables that you can use to customize your newly copied `.en | Amazon (CA) | `amazon-ca`| | ASUS | `asus` | | Best Buy | `bestbuy`| +| Best Buy (CA) | `bestbuy-ca`| | B&H | `bandh`| | EVGA | `evga`| | EVGA (EU) | `evga-eu`| diff --git a/src/store/lookup.ts b/src/store/lookup.ts index cd0ec00..24b080a 100644 --- a/src/store/lookup.ts +++ b/src/store/lookup.ts @@ -69,7 +69,8 @@ async function lookup(browser: Browser, store: Store) { } async function lookupCard(browser: Browser, store: Store, page: Page, link: Link) { - const response: Response | null = await page.goto(link.url, {waitUntil: 'networkidle0'}); + const givenWaitFor = store.customWaitFor ? store.customWaitFor : 'networkidle0'; + const response: Response | null = await page.goto(link.url, {waitUntil: givenWaitFor}); const graphicsCard = `${link.brand} ${link.model}`; if (await lookupCardInStock(store, page)) { diff --git a/src/store/model/bestbuy-ca.ts b/src/store/model/bestbuy-ca.ts new file mode 100644 index 0000000..daacd4b --- /dev/null +++ b/src/store/model/bestbuy-ca.ts @@ -0,0 +1,26 @@ +import {Store} from './store'; + +export const BestBuyCa: Store = { + customWaitFor: 'domcontentloaded', + labels: { + inStock: { + container: '#root', + text: ['available online'] + } + }, + links: [ + { + brand: 'TEST', + model: 'CARD', + series: 'debug', + url: 'https://www.bestbuy.ca/en-ca/product/msi-nvidia-geforce-rtx-2060-super-gaming-x-8gb-gddr6-video-card/14419420?intl=nosplash' + }, + { + brand: 'zotac', + model: 'trinity', + series: '3080', + url: 'https://www.bestbuy.ca/en-ca/product/zotac-geforce-rtx-3080-trinity-10gb-gddr6x-video-card/14953249?intl=nosplash' + } + ], + name: 'bestbuy-ca' +}; diff --git a/src/store/model/index.ts b/src/store/model/index.ts index ce5b2c1..a652af0 100644 --- a/src/store/model/index.ts +++ b/src/store/model/index.ts @@ -5,6 +5,7 @@ import {AmazonCa} from './amazon-ca'; import {Asus} from './asus'; import {BAndH} from './bandh'; import {BestBuy} from './bestbuy'; +import {BestBuyCa} from './bestbuy-ca'; import {Config} from '../../config'; import {Evga} from './evga'; import {EvgaEu} from './evga-eu'; @@ -23,6 +24,7 @@ const masterList = new Map([ [Asus.name, Asus], [BAndH.name, BAndH], [BestBuy.name, BestBuy], + [BestBuyCa.name, BestBuyCa], [Evga.name, Evga], [EvgaEu.name, EvgaEu], [MicroCenter.name, MicroCenter], diff --git a/src/store/model/store.ts b/src/store/model/store.ts index 8b235ec..e06cb01 100644 --- a/src/store/model/store.ts +++ b/src/store/model/store.ts @@ -1,4 +1,4 @@ -import {Browser} from 'puppeteer'; +import {Browser, LoadEvent} from 'puppeteer'; export interface Element { container: string; @@ -25,4 +25,5 @@ export interface Store { labels: Labels; name: string; setupAction?: (browser: Browser) => void; + customWaitFor?: LoadEvent; }