Skip to content

Commit cf20cd6

Browse files
committed
Fixed detection issue in Windows.
1 parent 9473cc4 commit cf20cd6

File tree

6 files changed

+39
-17
lines changed

6 files changed

+39
-17
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async function test() {
9090
connectOption: {},
9191

9292
disableXvfb: false,
93-
93+
ignoreAllFlags: false
9494
// proxy:{
9595
// host:'<proxy-host>',
9696
// port:'<proxy-port>',
@@ -103,20 +103,23 @@ async function test() {
103103

104104
}
105105

106+
test()
106107
```
107108

108109
**headless**: The default value is false. Values such as “new”, true, “shell” can also be sent, but it works most stable when false is used.
109110

110111
**args:** If there is an additional flag you want to add when starting Chromium, you can send it with this string.
111112

112-
**customConfig:** When launch is executed, the variables you send in be object are added. For example, you can specify the browser path with executablePath.
113+
**customConfig:** https://github.com/GoogleChrome/chrome-launcher The browser is initialized with this library. What you send with this object is added as a direct initialization argument. You should use the initialization values in this repo. You should set the userDataDir option here and if you want to specify a custom chrome path, you should set it with the chromePath value.
113114

114115
**turnstile:** Cloudflare Turnstile automatically clicks on Captchas if set to true
115116

116117
**connectOption:** The variables you send when connecting to chromium created with puppeteer.connect are added
117118

118119
**disableXvfb:** In Linux, when headless is false, a virtual screen is created and the browser is run there. You can set this value to true if you want to see the browser.
119120

121+
**ignoreAllFlags** If true, all initialization arguments are overridden. This includes the let's get started page that appears on the first load.
122+
120123
## How to Install Puppeteer-extra Plugins?
121124
Some plugins, such as puppeteer-extra-plugin-anonymize-ua, may cause you to be detected. You can use the plugin installation test in the library's test file to see if it will cause you to be detected.
122125

lib/cjs/index.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Xvfb = require('xvfb');
44

55
process.env.REBROWSER_PATCHES_RUNTIME_FIX_MODE = "alwaysIsolated"
66
// process.env.REBROWSER_PATCHES_DEBUG = 1
7-
async function connect({ args = [], headless = false, customConfig = {}, proxy = {}, turnstile = false, connectOption = {}, disableXvfb = false, plugins = [] }) {
7+
async function connect({ args = [], headless = false, customConfig = {}, proxy = {}, turnstile = false, connectOption = {}, disableXvfb = false, plugins = [], ignoreAllFlags = false }) {
88
const { launch, Launcher } = await import('chrome-launcher');
99

1010
let xvfbsession = null
@@ -23,12 +23,21 @@ async function connect({ args = [], headless = false, customConfig = {}, proxy =
2323
}
2424

2525
const chrome = await launch({
26+
ignoreDefaultFlags: true,
2627
chromeFlags: [
27-
...Launcher.defaultFlags().filter(item => !item.includes("--disable-features")),
28-
...args, ...((headless !== false) ? [`--headless=${headless}`] : []),
29-
...((proxy && proxy.host && proxy.port) ? [`--proxy-server=${proxy.host}:${proxy.port}`] : []),
30-
'--disable-features=Translate,OptimizationHints,MediaRouter,DialMediaRouteProvider,CalculateNativeWinOcclusion,InterestFeedContentSuggestions,CertificateTransparencyComponentUpdater,AutofillServerCommunication,PrivacySandboxSettings4,AutomationControlled',
31-
"--no-sandbox"
28+
...(
29+
(ignoreAllFlags === true)
30+
? [
31+
...((proxy && proxy.host && proxy.port) ? [`--proxy-server=${proxy.host}:${proxy.port}`] : []),
32+
...args, ...((headless !== false) ? [`--headless=${headless}`] : []),
33+
] : [
34+
...Launcher.defaultFlags().filter(item => !item.includes("--disable-features") && !item.includes("component-update")),
35+
...args, ...((headless !== false) ? [`--headless=${headless}`] : []),
36+
...((proxy && proxy.host && proxy.port) ? [`--proxy-server=${proxy.host}:${proxy.port}`] : []),
37+
'--disable-features=Translate,OptimizationHints,MediaRouter,DialMediaRouteProvider,CalculateNativeWinOcclusion,InterestFeedContentSuggestions,CertificateTransparencyComponentUpdater,AutofillServerCommunication,PrivacySandboxSettings4,AutomationControlled',
38+
"--no-sandbox"
39+
]
40+
),
3241
],
3342
...customConfig
3443
});

lib/esm/index.mjs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Xvfb from 'xvfb';
55

66
process.env.REBROWSER_PATCHES_RUNTIME_FIX_MODE = "alwaysIsolated"
77
// process.env.REBROWSER_PATCHES_DEBUG=1
8-
export async function connect({ args = [], headless = false, customConfig = {}, proxy = {}, turnstile = false, connectOption = {}, disableXvfb = false, plugins = [] }) {
8+
export async function connect({ args = [], headless = false, customConfig = {}, proxy = {}, turnstile = false, connectOption = {}, disableXvfb = false, plugins = [], ignoreAllFlags = false }) {
99
let xvfbsession = null
1010
if (headless == 'auto') headless = false
1111

@@ -22,12 +22,21 @@ export async function connect({ args = [], headless = false, customConfig = {},
2222
}
2323

2424
const chrome = await launch({
25+
ignoreDefaultFlags: true,
2526
chromeFlags: [
26-
...Launcher.defaultFlags().filter(item => !item.includes("--disable-features")),
27-
...args, ...((headless !== false) ? [`--headless=${headless}`] : []),
28-
...((proxy && proxy.host && proxy.port) ? [`--proxy-server=${proxy.host}:${proxy.port}`] : []),
29-
'--disable-features=Translate,OptimizationHints,MediaRouter,DialMediaRouteProvider,CalculateNativeWinOcclusion,InterestFeedContentSuggestions,CertificateTransparencyComponentUpdater,AutofillServerCommunication,PrivacySandboxSettings4,AutomationControlled',
30-
"--no-sandbox"
27+
...(
28+
(ignoreAllFlags === true)
29+
? [
30+
...((proxy && proxy.host && proxy.port) ? [`--proxy-server=${proxy.host}:${proxy.port}`] : []),
31+
...args, ...((headless !== false) ? [`--headless=${headless}`] : []),
32+
] : [
33+
...Launcher.defaultFlags().filter(item => !item.includes("--disable-features") && !item.includes("component-update")),
34+
...args, ...((headless !== false) ? [`--headless=${headless}`] : []),
35+
...((proxy && proxy.host && proxy.port) ? [`--proxy-server=${proxy.host}:${proxy.port}`] : []),
36+
'--disable-features=Translate,OptimizationHints,MediaRouter,DialMediaRouteProvider,CalculateNativeWinOcclusion,InterestFeedContentSuggestions,CertificateTransparencyComponentUpdater,AutofillServerCommunication,PrivacySandboxSettings4,AutomationControlled',
37+
"--no-sandbox"
38+
]
39+
),
3140
],
3241
...customConfig
3342
});

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "puppeteer-real-browser",
3-
"version": "1.3.3",
3+
"version": "1.3.4",
44
"description": "This package is designed to bypass puppeteer's bot-detecting captchas such as Cloudflare. It acts like a real browser and can be managed with puppeteer.",
55
"main": "lib/cjs/index.js",
66
"module": "lib/esm/index.mjs",

test/esm/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const realBrowserOption = {
77
turnstile: true,
88
headless: false,
99
// disableXvfb: true,
10+
// ignoreAllFlags:true,
1011
customConfig: {},
1112
connectOption: {
1213
defaultViewport: null

0 commit comments

Comments
 (0)