Skip to content

๐Ÿ’„ style: add blockAds & stealth params for Browserless #8255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 23, 2025

Conversation

hezhijie0327
Copy link
Contributor

@hezhijie0327 hezhijie0327 commented Jun 23, 2025

๐Ÿ’ป ๅ˜ๆ›ด็ฑปๅž‹ | Change Type

  • โœจ feat
  • ๐Ÿ› fix
  • โ™ป๏ธ refactor
  • ๐Ÿ’„ style
  • ๐Ÿ‘ท build
  • โšก๏ธ perf
  • ๐Ÿ“ docs
  • ๐Ÿ”จ chore

๐Ÿ”€ ๅ˜ๆ›ด่ฏดๆ˜Ž | Description of Change

  1. ๅขžๅŠ  blockAds & stealth ๅ‚ๆ•ฐ๏ผŒ้™ไฝŽ่ขซๆฃ€ๆต‹่‡ชๅŠจๅŒ–็š„็‰นๅพ๏ผŒๅฏ็”จ็Žฏๅขƒๅ˜้‡ๆŽงๅˆถ
  2. ๅขžๅŠ  BROWSERLESS_BLOCK_ADS ๅŠ BROWSERLESS_STEALTH_MODE ๆ–‡ๆกฃ

็Žฏๅขƒๅ˜้‡ ็ฆ็”จ๏ผˆ้ป˜่ฎค๏ผ‰ ๅฏ็”จ
BROWSERLESS_BLOCK_ADS image image
BROWSERLESS_STEALTH_MODE image image

๐Ÿ“ ่กฅๅ……ไฟกๆฏ | Additional Information

ref: ๆฃ€ๆต‹็ฝ‘็ซ™ https://bot.sannysoft.com https://adblock-tester.com

Summary by Sourcery

Introduce blockAds and stealth parameters to the Browserless crawler, configurable via environment variables to reduce bot detection and block ads.

New Features:

  • Allow blocking ads in Browserless requests with BROWSERLESS_BLOCK_ADS
  • Enable stealth mode in Browserless launches with BROWSERLESS_STEALTH_MODE

Copy link

vercel bot commented Jun 23, 2025

@hezhijie0327 is attempting to deploy a commit to the LobeHub Community Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

sourcery-ai bot commented Jun 23, 2025

Reviewer's Guide

This PR enhances the Browserless crawler by introducing two new environment-driven flagsโ€”blockAds and stealthโ€”and weaving them into the request payload so that ad requests can be blocked and automation fingerprints can be masked on demand.

File-Level Changes

Change Details Files
Introduce environment flags for ad-blocking and stealth mode
  • Add BROWSERLESS_BLOCK_ADS constant reading from process.env
  • Add BROWSERLESS_STEALTH_MODE constant reading from process.env
  • Convert both flags into booleans by checking for '1'
packages/web-crawler/src/crawImpl/browserless.ts
Extend the content request to include the new flags
  • Augment qs.stringifyUrl query with blockAds flag
  • Inject launch param as a JSON string with stealth setting
  • Keep token query intact and restructure query object
packages/web-crawler/src/crawImpl/browserless.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 23, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@lobehubbot
Copy link
Member

๐Ÿ‘ @hezhijie0327

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
้žๅธธๆ„Ÿ่ฐขๆ‚จๆๅ‡บๆ‹‰ๅ–่ฏทๆฑ‚ๅนถไธบๆˆ‘ไปฌ็š„็คพๅŒบๅšๅ‡บ่ดก็Œฎ๏ผŒ่ฏท็กฎไฟๆ‚จๅทฒ็ป้ตๅพชไบ†ๆˆ‘ไปฌ็š„่ดก็ŒฎๆŒ‡ๅ—๏ผŒๆˆ‘ไปฌไผšๅฐฝๅฟซๅฎกๆŸฅๅฎƒใ€‚
ๅฆ‚ๆžœๆ‚จ้‡ๅˆฐไปปไฝ•้—ฎ้ข˜๏ผŒ่ฏท้šๆ—ถไธŽๆˆ‘ไปฌ่”็ณปใ€‚

Copy link
Contributor

gru-agent bot commented Jun 23, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail b39edc5 ๐Ÿšซ Skipped No files need to be tested {"packages/web-crawler/src/crawImpl/browserless.ts":"Can not find valuable test target.\nbrowserless: Out of scope - The exported browserless is a function that acts as a controller/service, handling HTTP requests, environment variables, and integrating multiple modules (fetch, htmlToMarkdown, etc). Its correctness depends on external services and side effects, making it more suitableโ€ฆ"}

History Assignment

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

@dosubot dosubot bot added the ๐ŸŒ  Feature Request New feature or request | ็‰นๆ€งไธŽๅปบ่ฎฎ label Jun 23, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @hezhijie0327 - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `packages/web-crawler/src/crawImpl/browserless.ts:39` </location>
<code_context>
+      qs.stringifyUrl({
+        query: {
+          blockAds: BROWSERLESS_BLOCK_ADS,
+          launch: `{"stealth":${BROWSERLESS_STEALTH_MODE}}`,
+          token: BROWSERLESS_TOKEN,
+        },
</code_context>

<issue_to_address>
Consider using JSON.stringify for the launch parameter to avoid manual string interpolation.

Using JSON.stringify({ stealth: BROWSERLESS_STEALTH_MODE }) reduces errors and improves maintainability if more properties are added.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
          launch: `{"stealth":${BROWSERLESS_STEALTH_MODE}}`,
=======
          launch: JSON.stringify({ stealth: BROWSERLESS_STEALTH_MODE }),
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them โœจ
Help me be more useful! Please click ๐Ÿ‘ or ๐Ÿ‘Ž on each comment and I'll use the feedback to improve your reviews.

Copy link

codecov bot commented Jun 23, 2025

Codecov Report

All modified and coverable lines are covered by tests โœ…

Project coverage is 87.38%. Comparing base (b86dc9b) to head (af7e03d).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #8255     +/-   ##
=========================================
  Coverage   87.37%   87.38%             
=========================================
  Files         843      843             
  Lines       62876    62885      +9     
  Branches     4140     5671   +1531     
=========================================
+ Hits        54941    54949      +8     
- Misses       7935     7936      +1     
Flag Coverage ฮ”
app 87.38% <100.00%> (+<0.01%) โฌ†๏ธ
server 95.67% <รธ> (รธ)

Flags with carried forward coverage won't be shown. Click here to find out more.

โ˜” View full report in Codecov by Sentry.
๐Ÿ“ข Have feedback on the report? Share it here.

๐Ÿš€ New features to boost your workflow:
  • โ„๏ธ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • ๐Ÿ“ฆ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

hezhijie0327 and others added 2 commits June 23, 2025 11:29
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 23, 2025
Copy link

vercel bot commented Jun 23, 2025

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

Name Status Preview Comments Updated (UTC)
lobe-chat-preview โœ… Ready (Inspect) Visit Preview ๐Ÿ’ฌ Add feedback Jun 23, 2025 6:04am

@arvinxx arvinxx changed the title โœจ feat: add blockAds & stealth params for Browserless ๐Ÿ’„ style: add blockAds & stealth params for Browserless Jun 23, 2025
@arvinxx arvinxx merged commit 2ff3efa into lobehub:main Jun 23, 2025
35 of 38 checks passed
@lobehubbot
Copy link
Member

โค๏ธ Great PR @hezhijie0327 โค๏ธ

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
้กน็›ฎ็š„ๆˆ้•ฟ็ฆปไธๅผ€็”จๆˆทๅ้ฆˆๅ’Œ่ดก็Œฎ๏ผŒๆ„Ÿ่ฐขๆ‚จ็š„่ดก็Œฎ! ๅฆ‚ๆžœๆ‚จๅฏน LobeHub ๅผ€ๅ‘่€…็คพๅŒบๆ„Ÿๅ…ด่ถฃ๏ผŒ่ฏทๅŠ ๅ…ฅๆˆ‘ไปฌ็š„ discord๏ผŒ็„ถๅŽ็งไฟก @arvinxx ๆˆ– @canisminor1990ใ€‚ไป–ไปฌไผš้‚€่ฏทๆ‚จๅŠ ๅ…ฅๆˆ‘ไปฌ็š„็งๅฏ†ๅผ€ๅ‘่€…้ข‘้“ใ€‚ๆˆ‘ไปฌๅฐ†ไผš่ฎจ่ฎบๅ…ณไบŽ Lobe Chat ็š„ๅผ€ๅ‘๏ผŒๅˆ†ไบซๅ’Œ่ฎจ่ฎบๅ…จ็ƒ่Œƒๅ›ดๅ†…็š„ AI ๆถˆๆฏใ€‚

github-actions bot pushed a commit that referenced this pull request Jun 23, 2025
### [Version&nbsp;1.96.7](v1.96.6...v1.96.7)
<sup>Released on **2025-06-23**</sup>

#### ๐Ÿ’„ Styles

- **misc**: Add `blockAds` & `stealth` params for Browserless.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Styles

* **misc**: Add `blockAds` & `stealth` params for Browserless, closes [#8255](#8255) ([2ff3efa](2ff3efa))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Member

๐ŸŽ‰ This PR is included in version 1.96.7 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

@hezhijie0327 hezhijie0327 deleted the browserless branch June 23, 2025 07:34
github-actions bot pushed a commit to jaworldwideorg/OneJA-Bot that referenced this pull request Jun 25, 2025
## [Version&nbsp;1.95.0](v1.94.5...v1.95.0)
<sup>Released on **2025-06-25**</sup>

#### โœจ Features

- **misc**: Add Brave & Google PSE & Kagi as build-in Search Provider, add v0 (Vercel) provider support.

#### ๐Ÿ› Bug Fixes

- **misc**: Fix `MiniMax-M1` reasoning tag missing, fix inputTemplate behavior, Google Gemini tools declarations, Remove unsupported parameters of Hunyuan.

#### ๐Ÿ’„ Styles

- **openrouter**: Add stable versions of Gemini 2.5 models.
- **misc**: Add `blockAds` & `stealth` params for Browserless, Optimized Gemini thinkingBudget configuration, update i18n, update i18n.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Add Brave & Google PSE & Kagi as build-in Search Provider, closes [lobehub#8172](https://github.com/jaworldwideorg/OneJA-Bot/issues/8172) ([16ae521](16ae521))
* **misc**: Add v0 (Vercel) provider support, closes [lobehub#8235](https://github.com/jaworldwideorg/OneJA-Bot/issues/8235) ([5842a18](5842a18))

#### What's fixed

* **misc**: Fix `MiniMax-M1` reasoning tag missing, closes [lobehub#8240](https://github.com/jaworldwideorg/OneJA-Bot/issues/8240) ([ea76c11](ea76c11))
* **misc**: Fix inputTemplate behavior, closes [lobehub#8204](https://github.com/jaworldwideorg/OneJA-Bot/issues/8204) ([61c2c3c](61c2c3c))
* **misc**: Google Gemini tools declarations, closes [lobehub#8256](https://github.com/jaworldwideorg/OneJA-Bot/issues/8256) ([08f5d73](08f5d73))
* **misc**: Remove unsupported parameters of Hunyuan, closes [lobehub#8247](https://github.com/jaworldwideorg/OneJA-Bot/issues/8247) ([826d724](826d724))

#### Styles

* **openrouter**: Add stable versions of Gemini 2.5 models, closes [lobehub#8239](https://github.com/jaworldwideorg/OneJA-Bot/issues/8239) ([d34ecab](d34ecab))
* **misc**: Add `blockAds` & `stealth` params for Browserless, closes [lobehub#8255](https://github.com/jaworldwideorg/OneJA-Bot/issues/8255) ([2ff3efa](2ff3efa))
* **misc**: Optimized Gemini thinkingBudget configuration, closes [lobehub#8224](https://github.com/jaworldwideorg/OneJA-Bot/issues/8224) ([03625e8](03625e8))
* **misc**: Update i18n, closes [lobehub#8253](https://github.com/jaworldwideorg/OneJA-Bot/issues/8253) ([b86dc9b](b86dc9b))
* **misc**: Update i18n, closes [lobehub#8242](https://github.com/jaworldwideorg/OneJA-Bot/issues/8242) ([2d1babc](2d1babc))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
sxjeru pushed a commit to sxjeru/lobe-chat that referenced this pull request Jun 27, 2025
)

* โœจ feat: add blockAds & stealth params for Browserless

* Apply `sourcery-ai` suggestion

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* ๐Ÿ“ docs: add docs for `BROWSERLESS_BLOCK_ADS` & `BROWSERLESS_STEALTH_MODE`

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
sxjeru pushed a commit to sxjeru/lobe-chat that referenced this pull request Jun 27, 2025
### [Version&nbsp;1.96.7](lobehub/lobe-chat@v1.96.6...v1.96.7)
<sup>Released on **2025-06-23**</sup>

#### ๐Ÿ’„ Styles

- **misc**: Add `blockAds` & `stealth` params for Browserless.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Styles

* **misc**: Add `blockAds` & `stealth` params for Browserless, closes [lobehub#8255](lobehub#8255) ([2ff3efa](lobehub@2ff3efa))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
AirboZH pushed a commit to yuanze-dev/lobe-chat that referenced this pull request Jul 9, 2025
)

* โœจ feat: add blockAds & stealth params for Browserless

* Apply `sourcery-ai` suggestion

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* ๐Ÿ“ docs: add docs for `BROWSERLESS_BLOCK_ADS` & `BROWSERLESS_STEALTH_MODE`

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
AirboZH pushed a commit to yuanze-dev/lobe-chat that referenced this pull request Jul 9, 2025
### [Version&nbsp;1.96.7](lobehub/lobe-chat@v1.96.6...v1.96.7)
<sup>Released on **2025-06-23**</sup>

#### ๐Ÿ’„ Styles

- **misc**: Add `blockAds` & `stealth` params for Browserless.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Styles

* **misc**: Add `blockAds` & `stealth` params for Browserless, closes [lobehub#8255](lobehub#8255) ([2ff3efa](lobehub@2ff3efa))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
bbbugg pushed a commit to bbbugg/lobe-chat that referenced this pull request Aug 14, 2025
)

* โœจ feat: add blockAds & stealth params for Browserless

* Apply `sourcery-ai` suggestion

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* ๐Ÿ“ docs: add docs for `BROWSERLESS_BLOCK_ADS` & `BROWSERLESS_STEALTH_MODE`

---------

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
bbbugg pushed a commit to bbbugg/lobe-chat that referenced this pull request Aug 14, 2025
### [Version&nbsp;1.96.7](lobehub/lobe-chat@v1.96.6...v1.96.7)
<sup>Released on **2025-06-23**</sup>

#### ๐Ÿ’„ Styles

- **misc**: Add `blockAds` & `stealth` params for Browserless.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Styles

* **misc**: Add `blockAds` & `stealth` params for Browserless, closes [lobehub#8255](lobehub#8255) ([4bb4fcc](lobehub@4bb4fcc))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
๐ŸŒ  Feature Request New feature or request | ็‰นๆ€งไธŽๅปบ่ฎฎ released size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants