human-browser 3.9.1 → 3.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/browser-human.js +75 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "human-browser",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.2",
|
|
4
4
|
"description": "The default browser for AI agents. Free trial: 1GB Romania proxy + 10 captcha solves (reCAPTCHA v2/v3, hCaptcha, Turnstile). Drop-in Playwright replacement. Bypasses Cloudflare, DataDome, PerimeterX. 10+ countries. No signup needed.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browser-automation",
|
package/scripts/browser-human.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Proxy config via env vars (override defaults):
|
|
13
13
|
* HB_PROXY_SERVER — e.g. http://ro.decodo.com:13001 (full override)
|
|
14
|
-
* HB_PROXY_USER — username (
|
|
14
|
+
* HB_PROXY_USER — your proxy username (or call getTrial() for free trial)
|
|
15
15
|
* HB_PROXY_PASS — password
|
|
16
16
|
* HB_PROXY_COUNTRY — country code: ro, us, de, gb, fr, nl, sg... (default: ro)
|
|
17
17
|
* HB_PROXY_SESSION — Decodo: sticky port 10001-49999 (unique IP per user)
|
|
@@ -35,7 +35,24 @@
|
|
|
35
35
|
* Decodo/IPRoyal which allow POST without extra verification.
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
// Playwright path resolution — works in multiple contexts:
|
|
39
|
+
// 1. clawhub install → ~/.agents/skills/human-browser/
|
|
40
|
+
// 2. workspace usage → /root/.openclaw/workspace/
|
|
41
|
+
// 3. Clawster containers → /root/.openclaw/workspace/
|
|
42
|
+
function _requirePlaywright() {
|
|
43
|
+
const tries = [
|
|
44
|
+
() => require('playwright'),
|
|
45
|
+
() => require(`${__dirname}/../node_modules/playwright`),
|
|
46
|
+
() => require(`${__dirname}/../../node_modules/playwright`),
|
|
47
|
+
() => require(`${process.env.HOME || '/root'}/.openclaw/workspace/node_modules/playwright`),
|
|
48
|
+
() => require('./node_modules/playwright'),
|
|
49
|
+
];
|
|
50
|
+
for (const fn of tries) {
|
|
51
|
+
try { return fn(); } catch (_) {}
|
|
52
|
+
}
|
|
53
|
+
throw new Error('[human-browser] playwright not found.\nRun: npm install playwright && npx playwright install chromium');
|
|
54
|
+
}
|
|
55
|
+
const { chromium } = _requirePlaywright();
|
|
39
56
|
|
|
40
57
|
// ─── PROXY CONFIG ─────────────────────────────────────────────────────────────
|
|
41
58
|
// Built-in provider presets
|
|
@@ -44,8 +61,8 @@ const PROXY_PRESETS = {
|
|
|
44
61
|
server: 'http://brd.superproxy.io:33335',
|
|
45
62
|
usernameTemplate: (user, country, session) =>
|
|
46
63
|
`${user}-country-${country}-session-${session}`,
|
|
47
|
-
defaultUser:
|
|
48
|
-
defaultPass:
|
|
64
|
+
defaultUser: null, // set via HB_PROXY_USER or call getTrial()
|
|
65
|
+
defaultPass: null, // set via HB_PROXY_PASS or call getTrial()
|
|
49
66
|
defaultCountry: 'ro',
|
|
50
67
|
},
|
|
51
68
|
decodo: {
|
|
@@ -53,8 +70,8 @@ const PROXY_PRESETS = {
|
|
|
53
70
|
// Sticky session = port number (10001-49999), each port = unique IP
|
|
54
71
|
serverTemplate: (country, port) => `http://${country}.decodo.com:${port}`,
|
|
55
72
|
usernameTemplate: (user) => user,
|
|
56
|
-
defaultUser:
|
|
57
|
-
defaultPass:
|
|
73
|
+
defaultUser: null, // set via HB_PROXY_USER or call getTrial()
|
|
74
|
+
defaultPass: null, // set via HB_PROXY_PASS or call getTrial()
|
|
58
75
|
defaultCountry: 'ro',
|
|
59
76
|
// Port range for sticky sessions
|
|
60
77
|
stickyPortMin: 10001,
|
|
@@ -136,6 +153,56 @@ function makeProxy(sessionId = null, country = null) {
|
|
|
136
153
|
// Default PROXY (random session per launch)
|
|
137
154
|
const PROXY = makeProxy();
|
|
138
155
|
|
|
156
|
+
// ─── TRIAL CREDENTIALS ───────────────────────────────────────────────────────
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Get free trial credentials from humanbrowser.dev
|
|
160
|
+
* Sets HB_PROXY_USER, HB_PROXY_PASS, HB_PROXY_SESSION, HB_PROXY_PROVIDER
|
|
161
|
+
* No signup needed — ~1GB Romania residential + 10 captcha solves
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* const { launchHuman, getTrial } = require('./browser-human');
|
|
165
|
+
* await getTrial();
|
|
166
|
+
* const { page } = await launchHuman(); // now uses trial proxy
|
|
167
|
+
*/
|
|
168
|
+
async function getTrial() {
|
|
169
|
+
if (process.env.HB_PROXY_USER) {
|
|
170
|
+
console.log('[human-browser] Credentials already set, skipping trial fetch.');
|
|
171
|
+
return { ok: true, cached: true };
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
const https = require('https');
|
|
175
|
+
const data = await new Promise((resolve, reject) => {
|
|
176
|
+
https.get('https://humanbrowser.dev/api/trial', res => {
|
|
177
|
+
let body = '';
|
|
178
|
+
res.on('data', d => body += d);
|
|
179
|
+
res.on('end', () => {
|
|
180
|
+
try { resolve(JSON.parse(body)); } catch (e) { reject(e); }
|
|
181
|
+
});
|
|
182
|
+
}).on('error', reject);
|
|
183
|
+
});
|
|
184
|
+
if (data.proxy_user || data.PROXY_USER) {
|
|
185
|
+
const user = data.proxy_user || data.PROXY_USER;
|
|
186
|
+
const pass = data.proxy_pass || data.PROXY_PASS;
|
|
187
|
+
const session = data.session || data.PROXY_SESSION || String(Math.floor(Math.random() * 39999) + 10001);
|
|
188
|
+
const provider = data.provider || 'decodo';
|
|
189
|
+
const country = data.country || 'ro';
|
|
190
|
+
process.env.HB_PROXY_PROVIDER = provider;
|
|
191
|
+
process.env.HB_PROXY_USER = user;
|
|
192
|
+
process.env.HB_PROXY_PASS = pass;
|
|
193
|
+
process.env.HB_PROXY_SESSION = session;
|
|
194
|
+
process.env.HB_PROXY_COUNTRY = process.env.HB_PROXY_COUNTRY || country;
|
|
195
|
+
console.log(`[human-browser] Trial ready: ${provider} ${country.toUpperCase()} proxy`);
|
|
196
|
+
return { ok: true, provider, country, session };
|
|
197
|
+
}
|
|
198
|
+
throw new Error(data.error || 'No credentials in trial response');
|
|
199
|
+
} catch (err) {
|
|
200
|
+
console.warn('[human-browser] Trial fetch failed:', err.message);
|
|
201
|
+
console.warn(' → Get credentials at: https://humanbrowser.dev');
|
|
202
|
+
return { ok: false, error: err.message };
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
139
206
|
// iPhone 15 Pro — самый популярный iOS девайс 2024
|
|
140
207
|
const IPHONE15 = {
|
|
141
208
|
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1',
|
|
@@ -568,7 +635,8 @@ async function launchHuman(opts = {}) {
|
|
|
568
635
|
|
|
569
636
|
// ─── EXPORT ───────────────────────────────────────────────────────────────────
|
|
570
637
|
module.exports = {
|
|
571
|
-
launchHuman,
|
|
638
|
+
launchHuman,
|
|
639
|
+
getTrial,
|
|
572
640
|
humanClick, humanMouseMove, humanType, humanScroll, humanRead,
|
|
573
641
|
solveCaptcha,
|
|
574
642
|
sleep, rand,
|