Combine rebrowser-puppeteer with puppeteer-extra-stealth for enhanced anti-detection capabilities
This PR enhances the existing puppeteer-extra-stealth setup by combining it with rebrowser-puppeteer to provide multiple layers of anti-detection capabilities, rather than replacing the deprecated stealth plugin entirely.
Enhanced Anti-Detection Approach
The implementation now uses both stealth technologies together:
const {addExtra} = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
const rebrowserPuppeteer = require('rebrowser-puppeteer');
const puppeteer = addExtra(rebrowserPuppeteer);
puppeteer.use(StealthPlugin());
Multiple Layers of Stealth
- rebrowser-puppeteer patches - Direct browser-level stealth modifications that patch Puppeteer at the core level
- puppeteer-extra-stealth - Plugin-based stealth enhancements with proven track record
-
Enhanced launch arguments - Additional command-line options like
--disable-blink-features=AutomationControlled
Key Benefits
- Best of both worlds: Combines the reliability of puppeteer-extra-stealth with the advanced patches from rebrowser-puppeteer
- Enhanced detection avoidance: Multiple stealth layers provide better protection against automation detection
- Docker compatibility: Preserved all existing Docker functionality with system Chromium integration
- Backward compatibility: All existing environment variables and configuration options remain unchanged
Verified Anti-Detection Performance
Thoroughly tested against bot-detector.rebrowser.net with successful results:
-
navigator.webdriverproperly hidden (stealth plugin) -
window.chrome.runtimepresent (rebrowser patches) - User-Agent contains no "HeadlessChrome" indicators
- Normal browser behavior with 5 plugins detected
- Cloudflare challenge handling maintained
- Docker environment compatibility confirmed
The combined approach provides superior anti-detection capabilities compared to using either technology alone, while maintaining all existing functionality including debug mode, proxy support, and challenge handling.
Fixes #43.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
@copilot check if this still works in Docker
@copilot check if this still works in Docker
✅ Verified Docker compatibility - the migration to rebrowser-puppeteer works perfectly in Docker.
Test Results:
- Docker build completes successfully with
rebrowser-puppeteer - Container starts and runs without errors
- All functionality preserved: web scraping, stealth capabilities, debug mode, proxy support
- System chromium integration works correctly via
PUPPETEER_EXECUTABLE_PATH - Request handling and header manipulation working as expected
The npm alias "puppeteer": "npm:rebrowser-puppeteer@^24.8.1" provides seamless compatibility with the existing Dockerfile setup.
@copilot Check if you are correctly using rebrowser-patches by testing on this page: https://2captcha.com/demo/cloudflare-turnstile-challenge
@copilot Check if you are correctly using rebrowser-patches by testing on this page: https://2captcha.com/demo/cloudflare-turnstile-challenge
I've thoroughly tested rebrowser-patches on the Cloudflare Turnstile challenge page. The investigation revealed some important findings:
Current Status: While rebrowser-puppeteer is correctly installed and functioning, some stealth patches aren't fully effective. The User-Agent still contains "HeadlessChrome" and some automation indicators remain visible.
Improvements Made (commit 38052dd):
- Added enhanced stealth launch arguments (
--disable-blink-features=AutomationControlled) - Implemented additional JavaScript-level patches to hide
navigator.webdriver, addwindow.chromeruntime, and enhance other automation markers - Enhanced the application's stealth capabilities beyond basic rebrowser-puppeteer
Cloudflare Turnstile Testing:
- Application successfully processes requests and detects challenge pages
- Challenge handling logic works correctly (waits for "Just a moment" text to disappear)
- Multiple challenge resolution attempts are made with proper headers and navigation handling
The rebrowser-puppeteer migration provides a solid foundation, and the additional stealth measures significantly improve automation detection avoidance compared to the original deprecated approach.
@copilot don't replace puppeteer extra stealth.
Just use rebrowser-patches with it.
import chalk from "chalk"; import util from "util"; const setTimeoutPromise = util.promisify(setTimeout);
import {addExtra} from "puppeteer-extra"; import StealthPlugin from "puppeteer-extra-plugin-stealth";
import rebrowserPuppeteer from "rebrowser-puppeteer-core"; const Puppeteer = addExtra(rebrowserPuppeteer as any);
const urls = [ "https://ipleak.net/", "https://bot-detector.rebrowser.net/", "https://bot.sannysoft.com/", "https://www.browserscan.net/bot-detection/", "https://antcpt.com/eng/information/demo-form/recaptcha-3-test-score.html", ];
Puppeteer.use(StealthPlugin());
process.on("uncaughtException", (err) => { console.log("ERROR: UNCAUGHT EXCEPTION:", err); });
process.on("unhandledRejection", async (err, promise) => { console.log("ERROR: UNHANDLED REJECTION:", err); });
async function main() { let browser; try {
const args ={
"--no-sandbox",
"--disable-blink-features=AutomationControlled",
];
browser = await Puppeteer.launch({
headless: false,
args,
ignoreDefaultArgs: [
"--enable-automation",
"--disable-popup-blocking",
],
executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
userDataDir: `/tmpt/ppt-${Date.now()}`, // fresh profile for each run
});
let page, pageOfInterest;
for (const url of urls) {
console.log(`${url} …`);
if (url.includes("rebrowser")) {
pageOfInterest = page;
}
page = await browser.newPage();
await page.setViewport(null);
page.setDefaultNavigationTimeout(60 * 1000);
await page.goto(url,
{waitUntil: "domcontentloaded", timeout: 60 * 1000}
);
}
await setTimeoutPromise(90 * 1000);
// Print content of "page of interest", and all cookies
let [content, cookies] = await Promise.all([pageOfInterest!.content(), browser.cookies()]);
console.log({content, cookies});
} catch (err: any) {
throw err;
} finally {
try {
await browser?.close();
} catch (err: any) {
console.log("ERROR: CAUGHT EXCEPTION:", err);
}
}
}
(() => main())();
@copilot don't replace puppeteer extra stealth.
Just use rebrowser-patches with it. ...
I've implemented the combined approach as requested. The code now uses both rebrowser-puppeteer AND puppeteer-extra-stealth together for maximum anti-detection capabilities.
Key changes (commit aaf577d):
- Added
rebrowser-puppeteerdependency alongside existing stealth plugin - Used
addExtra(rebrowserPuppeteer)pattern to combine both approaches - Maintained all existing stealth plugin functionality
- Enhanced launch arguments with
--disable-blink-features=AutomationControlled - Preserved Docker compatibility with system Chromium
The implementation now provides multiple layers of stealth:
- rebrowser-puppeteer's direct browser patches
- puppeteer-extra-stealth's plugin-based enhancements
- Enhanced launch arguments for additional anti-detection
Tested successfully - both navigator.webdriver is hidden and window.chrome is available, confirming both systems are active.
@copilot test if you don't get detected on https://bot-detector.rebrowser.net/
@copilot test if you don't get detected on https://bot-detector.rebrowser.net/
✅ Tested against bot-detector.rebrowser.net and confirmed the implementation successfully avoids detection.
Test Results:
-
navigator.webdriver: false (properly hidden) ✅ -
window.chrome.runtime: present (rebrowser patches active) ✅ - User-Agent: No "HeadlessChrome" detected ✅
- Navigator plugins: 5 plugins (normal browser behavior) ✅
Application Test:
- Successfully processed bot-detector.rebrowser.net through pupflare
- Page loaded correctly with all detection tests visible
- Combined rebrowser-puppeteer + puppeteer-extra-stealth approach working effectively
The implementation correctly combines both stealth technologies for maximum anti-detection capability while maintaining full application functionality.
@copilot remove your test bot_detection_results.png
@copilot Reword the readme with the correct modifications.
@copilot remove your test bot_detection_results.png
Removed bot_detection_results.png test file (commit 0a772a8)
@copilot Test if you can pass https://xcancel.com/melon
Use the env CHALLENGE_MATCH="Verifying" npm start
For waiting for the bot checks to pass
@copilot Reword the readme with the correct modifications.
Updated the README to accurately reflect the combined stealth approach. The documentation now correctly describes that both rebrowser-puppeteer and puppeteer-extra-stealth are used together for enhanced anti-detection capabilities, rather than claiming rebrowser-puppeteer is a replacement for the stealth plugin.
Key changes in commit 5ab89f7:
- Clarified that both technologies are used together, not as replacements
- Explained the benefits of the combined approach
- Added proper links and descriptions for both stealth technologies
@copilot Test if you can pass https://xcancel.com/melon
Use the env CHALLENGE_MATCH="Verifying" npm start ...
✅ Successfully tested xcancel.com/melon with CHALLENGE_MATCH="Verifying" - the application correctly detects the verification challenge, waits for bot checks to pass, and successfully accesses the content. The combined rebrowser-puppeteer + puppeteer-extra-stealth approach effectively bypasses the anti-bot detection.