You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'--disable-infobars',// Hide "Chrome is being controlled" message
122
+
];
123
+
124
+
// Realistic viewport and user-agent for better evasion
125
+
constviewportConfig={width: 1920,height: 1080};
126
+
constuserAgent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36';
127
+
128
+
// Launch browser with extension
129
+
// Note: channel="chrome" (system Chrome) has known issues with extension loading
130
+
// We use bundled Chromium for reliable extension loading, but still apply stealth features
131
+
constuseChromeChannel=false;// Disabled for now due to extension loading issues
132
+
114
133
try{
115
-
this.context=awaitPromise.race([
116
-
chromium.launchPersistentContext(userDataDir,{
117
-
headless: this.headless,
118
-
args: [
119
-
`--load-extension=${tempDir}`,
120
-
`--disable-extensions-except=${tempDir}`,
121
-
],
122
-
timeout: launchTimeout,
123
-
}),
124
-
newPromise<never>((_,reject)=>
125
-
setTimeout(()=>reject(newError(`Browser launch timed out after ${launchTimeout}ms. Make sure Playwright browsers are installed: npx playwright install chromium`)),launchTimeout)
126
-
),
127
-
]);
128
-
}catch(e: any){
134
+
if(useChromeChannel){
135
+
// Try with system Chrome first (better evasion, but may have extension issues)
136
+
this.context=awaitPromise.race([
137
+
chromium.launchPersistentContext(userDataDir,{
138
+
channel: 'chrome',// Use system Chrome (better evasion)
139
+
headless: this.headless,
140
+
args: stealthArgs,
141
+
viewport: viewportConfig,
142
+
userAgent: userAgent,
143
+
timeout: launchTimeout,
144
+
}),
145
+
newPromise<never>((_,reject)=>
146
+
setTimeout(()=>reject(newError(`Browser launch timed out after ${launchTimeout}ms. Make sure Playwright browsers are installed: npx playwright install chromium`)),launchTimeout)
147
+
),
148
+
]);
149
+
}else{
150
+
// Use bundled Chromium (more reliable for extensions)
151
+
this.context=awaitPromise.race([
152
+
chromium.launchPersistentContext(userDataDir,{
153
+
headless: this.headless,
154
+
args: stealthArgs,
155
+
viewport: viewportConfig,
156
+
userAgent: userAgent,
157
+
timeout: launchTimeout,
158
+
}),
159
+
newPromise<never>((_,reject)=>
160
+
setTimeout(()=>reject(newError(`Browser launch timed out after ${launchTimeout}ms. Make sure Playwright browsers are installed: npx playwright install chromium`)),launchTimeout)
0 commit comments