export type MatchQuery = string | { selector?: string; tagName?: string; id?: string; attrs?: Record; }; export type ReplaceAction = { type: "replaceWithHtml"; html: string; } | { type: "replaceWithElement"; tagName: string; textContent?: string; html?: string; attrs?: Record; } | { type: "renameTag"; to: string; keepAttributes?: boolean; keepChildren?: boolean; } | { type: "remove"; }; export type ApplyOptions = { scope?: "document" | "allFrames"; limit?: number | "all"; onReplaced?: "stop" | "continue"; }; export type ReplaceElementRule = { name?: string; match: MatchQuery; replace: ReplaceAction; apply?: ApplyOptions; }; export type ReplaceElementContext<$ = unknown, $el = unknown> = { $: $; $el: $el; url: string; entryUrl: string; ruleIndex: number; matchIndex: number; }; export type ReplaceElementFn = (ctx: ReplaceElementContext) => void | ReplaceAction | ReplaceAction[] | Promise; export type ReplaceElementFnWithQuery = { query: string; apply?: ApplyOptions; run: ReplaceElementFn; }; export type ReplaceElementsConfig = Array;