Skip to content

Commit 4badae1

Browse files
krakenftwnsarrazin
andauthored
feat: playwright-adblocked toggle #1298 (#1301)
* feat: playwright-adblocked toggle * lint * Update src/lib/server/websearch/scrape/playwright.ts Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com> * replace regex with equality check --------- Co-authored-by: Nathan Sarrazin <sarrazin.nathan@gmail.com>
1 parent 2f0bb01 commit 4badae1

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SERPSTACK_API_KEY=#your serpstack api key here
2727
SEARCHAPI_KEY=#your searchapi api key here
2828
USE_LOCAL_WEBSEARCH=#set to true to parse google results yourself, overrides other API keys
2929
SEARXNG_QUERY_URL=# where '<query>' will be replaced with query keywords see https://docs.searxng.org/dev/search_api.html eg https://searxng.yourdomain.com/search?q=<query>&engines=duckduckgo,google&format=json
30+
PLAYWRIGHT_ADBLOCKER=true
3031

3132
WEBSEARCH_ALLOWLIST=`[]` # if it's defined, allow websites from only this list.
3233
WEBSEARCH_BLOCKLIST=`[]` # if it's defined, block websites from this list.

src/lib/server/websearch/scrape/playwright.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function withPage<T>(
6565

6666
try {
6767
const page = await ctx.newPage();
68-
await blocker.enableBlockingInPage(page);
68+
process.env.PLAYWRIGHT_ADBLOCKER === "true" && (await blocker.enableBlockingInPage(page));
6969

7070
const res = await page.goto(url, { waitUntil: "load", timeout: 3500 }).catch(() => {
7171
console.warn(`Failed to load page within 2s: ${url}`);

0 commit comments

Comments
 (0)