mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 08:47:43 +00:00
feat(store): add custom labels for links (#1183)
Fixes #1132 Fixes #1163
This commit is contained in:
@@ -316,6 +316,19 @@ async function lookupCardInStock(store: Store, page: Page, link: Link) {
|
||||
}
|
||||
}
|
||||
|
||||
if (link.labels?.inStock) {
|
||||
const options = {
|
||||
...baseOptions,
|
||||
requireVisible: true,
|
||||
type: 'outerHTML' as const
|
||||
};
|
||||
|
||||
if (!(await pageIncludesLabels(page, link.labels.inStock, options))) {
|
||||
logger.info(Print.outOfStock(link, store, true));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (store.labels.outOfStock) {
|
||||
if (await pageIncludesLabels(page, store.labels.outOfStock, baseOptions)) {
|
||||
logger.info(Print.outOfStock(link, store, true));
|
||||
|
||||
@@ -510,6 +510,12 @@ export const AmazonDe: Store = {
|
||||
brand: 'sony',
|
||||
cartUrl:
|
||||
'https://www.amazon.de/gp/aws/cart/add.html?ASIN.1=B08H93ZRK9&Quantity.1=1',
|
||||
labels: {
|
||||
inStock: {
|
||||
container: '#productTitle',
|
||||
text: ['sony playstation 5']
|
||||
}
|
||||
},
|
||||
model: 'ps5 console',
|
||||
series: 'sonyps5c',
|
||||
url: 'https://www.amazon.de/dp/B08H93ZRK9'
|
||||
@@ -518,13 +524,19 @@ export const AmazonDe: Store = {
|
||||
brand: 'sony',
|
||||
cartUrl:
|
||||
'https://www.amazon.de/gp/aws/cart/add.html?ASIN.1=B08H98GVK8&Quantity.1=1',
|
||||
labels: {
|
||||
inStock: {
|
||||
container: '#productTitle',
|
||||
text: ['sony playstation 5']
|
||||
}
|
||||
},
|
||||
model: 'ps5 digital',
|
||||
series: 'sonyps5de',
|
||||
url: 'https://www.amazon.de/dp/B08H98GVK8'
|
||||
},
|
||||
{
|
||||
brand: 'microsoft',
|
||||
// Disabled because of #1095
|
||||
// Fixme: disabled because of #1095, enable when working again
|
||||
// cartUrl:
|
||||
// 'https://www.amazon.de/gp/aws/cart/add.html?ASIN.1=B08H93ZRLL&Quantity.1=1',
|
||||
model: 'xbox series x',
|
||||
@@ -533,7 +545,7 @@ export const AmazonDe: Store = {
|
||||
},
|
||||
{
|
||||
brand: 'microsoft',
|
||||
// Disabled because of #1095
|
||||
// Fixme: disabled because of #1095, enable when working again
|
||||
// cartUrl:
|
||||
// 'https://www.amazon.de/gp/aws/cart/add.html?ASIN.1=B087VM5XC6&Quantity.1=1',
|
||||
model: 'xbox series s',
|
||||
|
||||
@@ -28,6 +28,13 @@ export const Otto: Store = {
|
||||
},
|
||||
{
|
||||
brand: 'sony',
|
||||
labels: {
|
||||
inStock: {
|
||||
container:
|
||||
'.js_shortInfo__variationName.prd_shortInfo__variationName',
|
||||
text: ['konsole']
|
||||
}
|
||||
},
|
||||
model: 'ps5 console',
|
||||
series: 'sonyps5c',
|
||||
url:
|
||||
@@ -35,6 +42,13 @@ export const Otto: Store = {
|
||||
},
|
||||
{
|
||||
brand: 'sony',
|
||||
labels: {
|
||||
inStock: {
|
||||
container:
|
||||
'.js_shortInfo__variationName.prd_shortInfo__variationName',
|
||||
text: ['konsole']
|
||||
}
|
||||
},
|
||||
model: 'ps5 console',
|
||||
series: 'sonyps5c',
|
||||
url:
|
||||
@@ -42,6 +56,13 @@ export const Otto: Store = {
|
||||
},
|
||||
{
|
||||
brand: 'sony',
|
||||
labels: {
|
||||
inStock: {
|
||||
container:
|
||||
'.js_shortInfo__variationName.prd_shortInfo__variationName',
|
||||
text: ['konsole']
|
||||
}
|
||||
},
|
||||
model: 'ps5 digital',
|
||||
series: 'sonyps5de',
|
||||
url:
|
||||
|
||||
@@ -132,13 +132,14 @@ export type Model =
|
||||
|
||||
export type Link = {
|
||||
brand: Brand;
|
||||
itemNumber?: string;
|
||||
series: Series;
|
||||
model: Model;
|
||||
url: string;
|
||||
cartUrl?: string;
|
||||
itemNumber?: string;
|
||||
labels?: Labels;
|
||||
model: Model;
|
||||
openCartAction?: (browser: Browser) => Promise<string>;
|
||||
series: Series;
|
||||
screenshot?: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
export type LabelQuery = Element[] | Element | string[];
|
||||
|
||||
Reference in New Issue
Block a user