From 7b08471ba1cbb06198457c8a3ac92ee7b4201bd3 Mon Sep 17 00:00:00 2001 From: RohitR311 Date: Sat, 4 Jan 2025 15:37:35 +0530 Subject: [PATCH] feat: add func to rm iframe selector from workflow --- maxun-core/src/interpret.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/maxun-core/src/interpret.ts b/maxun-core/src/interpret.ts index 14d8f46e..e11ea517 100644 --- a/maxun-core/src/interpret.ts +++ b/maxun-core/src/interpret.ts @@ -658,8 +658,24 @@ export default class Interpreter extends EventEmitter { } } + private removeIframeSelectors(workflow: Workflow) { + for (let actionId = workflow.length - 1; actionId >= 0; actionId--) { + const step = workflow[actionId]; + + // Check if step has where and selectors + if (step.where && Array.isArray(step.where.selectors)) { + // Filter out selectors that contain ">>" + step.where.selectors = step.where.selectors.filter(selector => !selector.includes(':>>')); + } + } + + return workflow; + } + private async runLoop(p: Page, workflow: Workflow) { - const workflowCopy: Workflow = JSON.parse(JSON.stringify(workflow)); + let workflowCopy: Workflow = JSON.parse(JSON.stringify(workflow)); + + workflowCopy = this.removeIframeSelectors(workflowCopy); // apply ad-blocker to the current page await this.applyAdBlocker(p);