feat: add separate browser service

This commit is contained in:
Rohit Rajan
2025-11-30 17:41:44 +05:30
parent ad8df66ecd
commit cf19a72dc0
25 changed files with 355 additions and 72 deletions

View File

@@ -31,10 +31,10 @@
"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",
"playwright": "^1.20.1",
"playwright-extra": "^4.3.6",
"puppeteer-extra-plugin-stealth": "^2.11.2"
"playwright-core": "1.57.0",
"turndown": "^7.2.2"
}
}
}

View File

@@ -1,5 +1,5 @@
/* eslint-disable no-await-in-loop, no-restricted-syntax */
import { ElementHandle, Page, PageScreenshotOptions } from 'playwright';
import { ElementHandle, Page, PageScreenshotOptions } from 'playwright-core';
import { PlaywrightBlocker } from '@cliqz/adblocker-playwright';
import fetch from 'cross-fetch';
import path from 'path';
@@ -144,7 +144,7 @@ export default class Interpreter extends EventEmitter {
private async applyAdBlocker(page: Page): Promise<void> {
if (this.blocker) {
try {
await this.blocker.enableBlockingInPage(page);
await this.blocker.enableBlockingInPage(page as any);
} catch (err) {
this.log(`Ad-blocker operation failed:`, Level.ERROR);
}
@@ -154,7 +154,7 @@ export default class Interpreter extends EventEmitter {
private async disableAdBlocker(page: Page): Promise<void> {
if (this.blocker) {
try {
await this.blocker.disableBlockingInPage(page);
await this.blocker.disableBlockingInPage(page as any);
} catch (err) {
this.log(`Ad-blocker operation failed:`, Level.ERROR);
}

View File

@@ -1,4 +1,4 @@
import { Page } from 'playwright';
import { Page } from 'playwright-core';
import {
naryOperators, unaryOperators, operators, meta,
} from './logic';