From 2c795af8585fb71763092480e99fd3452b0e6d46 Mon Sep 17 00:00:00 2001 From: amhsirak Date: Sun, 4 Jan 2026 22:42:22 +0530 Subject: [PATCH] temp: remove adblocker --- maxun-core/package.json | 1 - maxun-core/src/interpret.ts | 53 ++++++------------------------------- 2 files changed, 8 insertions(+), 46 deletions(-) diff --git a/maxun-core/package.json b/maxun-core/package.json index 8c395192..cce98975 100644 --- a/maxun-core/package.json +++ b/maxun-core/package.json @@ -30,7 +30,6 @@ "author": "Maxun", "license": "AGPL-3.0-or-later", "dependencies": { - "@cliqz/adblocker-playwright": "^1.31.3", "@types/node": "22.7.9", "cross-fetch": "^4.0.0", "joi": "^17.6.0", diff --git a/maxun-core/src/interpret.ts b/maxun-core/src/interpret.ts index c6dd653b..86219309 100644 --- a/maxun-core/src/interpret.ts +++ b/maxun-core/src/interpret.ts @@ -1,6 +1,5 @@ /* eslint-disable no-await-in-loop, no-restricted-syntax */ import { ElementHandle, Page, PageScreenshotOptions } from 'playwright-core'; -import { PlaywrightBlocker } from '@cliqz/adblocker-playwright'; import fetch from 'cross-fetch'; import path from 'path'; @@ -70,7 +69,7 @@ export default class Interpreter extends EventEmitter { private log: typeof log; - private blocker: PlaywrightBlocker | null = null; + // private blocker: PlaywrightBlocker | null = null; private cumulativeResults: Record[] = []; @@ -125,13 +124,13 @@ export default class Interpreter extends EventEmitter { }; } - PlaywrightBlocker.fromLists(fetch, ['https://easylist.to/easylist/easylist.txt']).then(blocker => { - this.blocker = blocker; - }).catch(err => { - this.log(`Failed to initialize ad-blocker: ${err.message}`, Level.ERROR); - // Continue without ad-blocker rather than crashing - this.blocker = null; - }) + // PlaywrightBlocker.fromLists(fetch, ['https://easylist.to/easylist/easylist.txt']).then(blocker => { + // this.blocker = blocker; + // }).catch(err => { + // this.log(`Failed to initialize ad-blocker: ${err.message}`, Level.ERROR); + // // Continue without ad-blocker rather than crashing + // this.blocker = null; + // }) } /** @@ -148,26 +147,6 @@ export default class Interpreter extends EventEmitter { return this.isAborted; } - private async applyAdBlocker(page: Page): Promise { - if (this.blocker) { - try { - await this.blocker.enableBlockingInPage(page as any); - } catch (err) { - this.log(`Ad-blocker operation failed:`, Level.ERROR); - } - } - } - - private async disableAdBlocker(page: Page): Promise { - if (this.blocker) { - try { - await this.blocker.disableBlockingInPage(page as any); - } catch (err) { - this.log(`Ad-blocker operation failed:`, Level.ERROR); - } - } - } - // private getSelectors(workflow: Workflow, actionId: number): string[] { // const selectors: string[] = []; @@ -2210,12 +2189,6 @@ export default class Interpreter extends EventEmitter { workflowCopy = this.removeSpecialSelectors(workflowCopy); - // apply ad-blocker to the current page - try { - await this.applyAdBlocker(p); - } catch (error) { - this.log(`Failed to apply ad-blocker: ${error.message}`, Level.ERROR); - } const usedActions: string[] = []; let selectors: string[] = []; let lastAction = null; @@ -2495,16 +2468,6 @@ export default class Interpreter extends EventEmitter { } } - // Clear ad-blocker resources - if (this.blocker) { - try { - this.blocker = null; - this.log('Ad-blocker resources cleared', Level.DEBUG); - } catch (error: any) { - this.log(`Error cleaning up ad-blocker: ${error.message}`, Level.WARN); - } - } - // Clear accumulated data to free memory this.cumulativeResults = []; this.namedResults = {};