diff --git a/src/advertising/slise.ts b/src/advertising/slise.ts index 2851051..7bb4591 100644 --- a/src/advertising/slise.ts +++ b/src/advertising/slise.ts @@ -6,7 +6,7 @@ export interface SliseAdPlacesRule { selector: { isMultiple: boolean; cssString: string; - shouldUseResultParent: boolean; + parentDepth: number; shouldUseDivWrapper: boolean; }; } diff --git a/src/routers/slise-ad-rules/ad-places.ts b/src/routers/slise-ad-rules/ad-places.ts index c3c48b2..2ab3404 100644 --- a/src/routers/slise-ad-rules/ad-places.ts +++ b/src/routers/slise-ad-rules/ad-places.ts @@ -18,7 +18,7 @@ import { hostnamesListSchema, sliseAdPlacesRulesDictionarySchema } from '../../u * required: * - isMultiple * - cssString - * - shouldUseResultParent + * - parentDepth * - shouldUseDivWrapper * properties: * isMultiple: @@ -27,9 +27,12 @@ import { hostnamesListSchema, sliseAdPlacesRulesDictionarySchema } from '../../u * cssString: * type: string * description: CSS selector - * shouldUseResultParent: - * type: boolean - * description: Whether the results parents should be used as ads containers + * parentDepth: + * type: number + * description: > + * Indicates the depth of the parent element of the selected element, i. e. 0 means that the selected + * elements are ads containers themselves, 1 means that the selected elements are ads containers' direct + * children and so on. * shouldUseDivWrapper: * type: boolean * description: Whether the ads banner should be wrapped in a div @@ -52,7 +55,7 @@ import { hostnamesListSchema, sliseAdPlacesRulesDictionarySchema } from '../../u * selector: * isMultiple: false * cssString: 'main > section div.row > div:nth-child(2) > div' - * shouldUseResultParent: false + * parentDepth: 0 * shouldUseDivWrapper: false * SliseAdPlacesRulesDictionary: * type: object @@ -67,7 +70,7 @@ import { hostnamesListSchema, sliseAdPlacesRulesDictionarySchema } from '../../u * selector: * isMultiple: false * cssString: 'main > section div.row > div:nth-child(2) > div' - * shouldUseResultParent: false + * parentDepth: 0 * shouldUseDivWrapper: false * www.dextools.io: * - urlRegexes: @@ -75,14 +78,14 @@ import { hostnamesListSchema, sliseAdPlacesRulesDictionarySchema } from '../../u * selector: * isMultiple: true * cssString: 'app-header-banner' - * shouldUseResultParent: true + * parentDepth: 1 * shouldUseDivWrapper: false * - urlRegexes: * - '^https://www\.dextools\.io/app/[A-z]{2}/[0-9A-z-]+/pairs' * selector: * isMultiple: false * cssString: 'div.left-container > app-pe-banner:nth-child(2)' - * shouldUseResultParent: false + * parentDepth: 0 * shouldUseDivWrapper: true */ diff --git a/src/utils/schemas.ts b/src/utils/schemas.ts index 4568605..aafe02c 100644 --- a/src/utils/schemas.ts +++ b/src/utils/schemas.ts @@ -2,6 +2,7 @@ import { array as arraySchema, ArraySchema as IArraySchema, boolean as booleanSchema, + number as numberSchema, object as objectSchema, ObjectSchema as IObjectSchema, Schema, @@ -66,7 +67,7 @@ const sliseAdPlacesRulesSchema = arraySchema() selector: objectSchema().shape({ isMultiple: booleanSchema().required(), cssString: cssSelectorSchema.clone().required(), - shouldUseResultParent: booleanSchema().required(), + parentDepth: numberSchema().integer().min(0).required(), shouldUseDivWrapper: booleanSchema().required() }) })