/** * Core modal detection utilities * * This module contains the fundamental logic for detecting modals and overlays * on web pages. It uses a combination of: * - Visual analysis (position, z-index, viewport coverage) * - DOM structure analysis (ARIA attributes, common patterns) * - Reverse detection (elementFromPoint for accuracy) * * NOTE: Functions in this file are serialized and executed in browser context. * We use `as any` type assertions because these functions access DOM APIs * (window, document, Element) that aren't available in Node.js types. * At runtime, these functions execute in the browser where DOM APIs exist. */ /** * Modal type classification */ export type ModalType = 'cookie-consent' | 'newsletter-popup' | 'age-verification' | 'generic-dialog' | 'blocking-overlay' | 'unknown'; /** * Available dismiss strategies */ export type DismissStrategy = 'accept' | 'reject' | 'close' | 'remove'; /** * Bounding box coordinates */ export interface BoundingBox { x: number; y: number; width: number; height: number; } /** * Modal detection options */ export interface ModalDetectionOptions { minZIndex?: number; minViewportCoverage?: number; includeBackdrops?: boolean; } /** * Modal classification result */ export interface ModalClassification { type: ModalType; confidence: number; description: string; } /** * Detected modal information (returned from page.evaluate) */ export interface DetectedModalInfo { selector: string; type: ModalType; zIndex: number; boundingBox: BoundingBox; dismissStrategies: DismissStrategy[]; confidence: number; description: string; } /** * Browser-side modal detection types * These types are used within page.evaluate() context */ export interface BrowserModalInfo { selector: string; type: string; zIndex: number; boundingBox: { x: number; y: number; width: number; height: number; }; dismissStrategies: string[]; confidence: number; description: string; } /** * Common modal/dialog selectors and patterns */ export declare const MODAL_PATTERNS: { cookieConsent: { selectors: string[]; textPatterns: RegExp; }; newsletter: { selectors: string[]; textPatterns: RegExp; }; ageVerification: { selectors: string[]; textPatterns: RegExp; }; genericDialog: { selectors: string[]; textPatterns: null; }; }; /** * Common selectors for finding modal elements */ export declare const COMMON_MODAL_SELECTORS: string[]; /** * Check if element meets basic visibility criteria * Runs in browser context via page.evaluate() */ export declare function isBasicVisible(el: any): boolean; /** * Check if element is positioned to block viewport * Runs in browser context via page.evaluate() */ export declare function isBlockingPosition(el: any): boolean; /** * Check if element has sufficient z-index * Runs in browser context via page.evaluate() */ export declare function hasMinimumZIndex(el: any, minZIndex: number): boolean; /** * Check if element covers sufficient viewport area * Runs in browser context via page.evaluate() */ export declare function coversMinimumViewport(el: any, minCoverage: number): boolean; /** * Check if element is actually visible on top using elementFromPoint * This is the most reliable method - it verifies the element is truly on top * Runs in browser context via page.evaluate() */ export declare function isVisibleOnTop(el: any): boolean; /** * Combined check: is element blocking the viewport? * Uses all visibility checks including elementFromPoint for accuracy * Runs in browser context via page.evaluate() */ export declare function isElementBlockingViewport(el: any, minZIndex: number, minViewportCoverage: number): boolean; /** * Classify modal type based on content and attributes * Runs in browser context via page.evaluate() */ export declare function classifyModal(el: any, patterns: typeof MODAL_PATTERNS): ModalClassification; /** * Determine dismissal strategies available for a modal * Runs in browser context via page.evaluate() */ export declare function getDismissStrategies(el: any, modalType: string): DismissStrategy[]; /** * Generate unique CSS selector for an element * Runs in browser context via page.evaluate() */ export declare function getUniqueSelector(el: any): string; //# sourceMappingURL=modal-detection-core.d.ts.map