Skip to content

Commit

Permalink
chore(store): add xbox to bestbuy-ca and amazon-ca
Browse files Browse the repository at this point in the history
Resolves #982
  • Loading branch information
jef committed Dec 8, 2020
1 parent 5aa4fdc commit d56bcdd
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/store/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,15 @@ async function lookupCardInStock(store: Store, page: Page, link: Link) {
// return store.realTimeInventoryLookup(link.itemNumber);
// }

if (store.labels.outOfStock) {
if (
await pageIncludesLabels(page, store.labels.outOfStock, baseOptions)
) {
logger.info(Print.outOfStock(link, store, true));
return false;
}
}

if (store.labels.inStock) {
const options = {
...baseOptions,
Expand All @@ -373,15 +382,6 @@ async function lookupCardInStock(store: Store, page: Page, link: Link) {
}
}

if (store.labels.outOfStock) {
if (
await pageIncludesLabels(page, store.labels.outOfStock, baseOptions)
) {
logger.info(Print.outOfStock(link, store, true));
return false;
}
}

return true;
}

Expand Down
16 changes: 16 additions & 0 deletions src/store/model/amazon-ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,22 @@ export const AmazonCa: Store = {
model: 'ps5 digital',
series: 'sonyps5de',
url: 'https://www.amazon.ca/dp/B08GS1N24H'
},
{
brand: 'microsoft',
cartUrl:
'https://www.amazon.ca/gp/aws/cart/add.html?ASIN.1=B08H75RTZ8&Quantity.1=1',
model: 'xbox series x',
series: 'xboxsx',
url: 'https://www.amazon.ca/dp/B08H75RTZ8'
},
{
brand: 'microsoft',
cartUrl:
'https://www.amazon.ca/gp/aws/cart/add.html?ASIN.1=B08G9J44ZN&Quantity.1=1',
model: 'xbox series s',
series: 'xboxss',
url: 'https://www.amazon.ca/dp/B08G9J44ZN'
}
],
name: 'amazon-ca'
Expand Down
25 changes: 19 additions & 6 deletions src/store/model/bestbuy-ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import {Store} from './store';
export const BestBuyCa: Store = {
labels: {
inStock: {
container: '.x-checkout-experience-new',
container: '.addToCartContainer_2uzan',
text: ['add to cart']
},
maxPrice: {
container:
'div[class^="productPricingContainer"] span[class^="screenReaderOnly_"',
container: '.pricingContainer_25k3c',
euroFormat: false
},
outOfStock: {
container: 'button.addToCartButton.disabled_XY3i_',
text: ['Add to Cart']
container: '.shippingAvailability_2RMa1',
text: ['coming soon']
}
},
links: [
Expand All @@ -22,7 +21,7 @@ export const BestBuyCa: Store = {
model: 'test:model',
series: 'test:series',
url:
'https://www.bestbuy.ca/en-ca/product/evga-geforce-gtx-1660-xc-ultra-6gb-gddr5-video-card/14119081?intl=nosplash'
'https://www.bestbuy.ca/en-ca/product/zotac-nvidia-geforce-gtx-1660-super-twin-fan-6gb-gddr6-video-card/14415897'
},
{
brand: 'msi',
Expand Down Expand Up @@ -163,6 +162,20 @@ export const BestBuyCa: Store = {
series: 'sonyps5de',
url:
'https://www.bestbuy.ca/en-ca/product/playstation-5-digital-edition-console-online-only/14962184?intl=nosplash'
},
{
brand: 'microsoft',
model: 'xbox series x',
series: 'xboxsx',
url:
'https://www.bestbuy.ca/en-ca/product/xbox-series-x-1tb-console-new-model-online-only/14964951'
},
{
brand: 'microsoft',
model: 'xbox series s',
series: 'xboxss',
url:
'https://www.bestbuy.ca/en-ca/product/xbox-series-s-512gb-console-new-model-online-only/14964950'
}
],
name: 'bestbuy-ca',
Expand Down
3 changes: 1 addition & 2 deletions src/store/model/bestbuy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export const BestBuy: Store = {
},
maxPrice: {
container:
'[data-sticky-media-gallery] .priceView-price .priceView-hero-price span',
euroFormat: false
'[data-sticky-media-gallery] .priceView-price .priceView-hero-price span'
}
},
links: [
Expand Down

0 comments on commit d56bcdd

Please sign in to comment.