brave-real-browser 2.0.1 → 2.0.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/lib/cjs/index.js +1 -0
- package/lib/esm/index.mjs +1 -0
- package/package.json +1 -1
- package/test/cjs/test.js +21 -35
- package/test/esm/test.js +20 -36
package/lib/cjs/index.js
CHANGED
package/lib/esm/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brave-real-browser",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"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.",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.mjs",
|
package/test/cjs/test.js
CHANGED
|
@@ -2,53 +2,50 @@ const test = require('node:test');
|
|
|
2
2
|
const assert = require('node:assert');
|
|
3
3
|
const { connect } = require('../../lib/cjs/index.js');
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
const realBrowserOption = {
|
|
7
|
-
args: ["--start-minimized"],
|
|
8
6
|
turnstile: true,
|
|
9
7
|
headless: false,
|
|
10
|
-
// disableXvfb: true,
|
|
11
8
|
customConfig: {},
|
|
12
|
-
connectOption: {
|
|
13
|
-
defaultViewport: null
|
|
14
|
-
},
|
|
15
9
|
plugins: []
|
|
16
10
|
}
|
|
17
11
|
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
// Shared browser instance for all tests
|
|
13
|
+
let browser = null;
|
|
14
|
+
let page = null;
|
|
15
|
+
|
|
16
|
+
// Setup - Run once before all tests
|
|
17
|
+
test.before(async () => {
|
|
18
|
+
console.log('🚀 Starting browser for all tests...');
|
|
19
|
+
const result = await connect(realBrowserOption);
|
|
20
|
+
browser = result.browser;
|
|
21
|
+
page = result.page;
|
|
22
|
+
console.log('✅ Browser started successfully');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Teardown - Run once after all tests
|
|
26
|
+
test.after(async () => {
|
|
27
|
+
console.log('🏁 Closing browser after all tests...');
|
|
28
|
+
if (browser) {
|
|
29
|
+
await browser.close();
|
|
30
|
+
console.log('✅ Browser closed successfully');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
31
33
|
|
|
32
34
|
test('DrissionPage Detector', async () => {
|
|
33
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
34
35
|
await page.goto("https://web.archive.org/web/20240913054632/https://drissionpage.pages.dev/");
|
|
35
36
|
await page.realClick("#detector")
|
|
36
37
|
let result = await page.evaluate(() => { return document.querySelector('#isBot span').textContent.includes("not") ? true : false })
|
|
37
|
-
await browser.close()
|
|
38
38
|
assert.strictEqual(result, true, "DrissionPage Detector test failed!")
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
test('Brotector, a webdriver detector', async () => {
|
|
42
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
43
42
|
await page.goto("https://kaliiiiiiiiii.github.io/brotector/");
|
|
44
43
|
await new Promise(r => setTimeout(r, 3000));
|
|
45
44
|
let result = await page.evaluate(() => { return document.querySelector('#table-keys').getAttribute('bgcolor') })
|
|
46
|
-
await browser.close()
|
|
47
45
|
assert.strictEqual(result === "darkgreen", true, "Brotector, a webdriver detector test failed!")
|
|
48
46
|
})
|
|
49
47
|
|
|
50
48
|
test('Cloudflare WAF', async () => {
|
|
51
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
52
49
|
await page.goto("https://nopecha.com/demo/cloudflare");
|
|
53
50
|
let verify = null
|
|
54
51
|
let startDate = Date.now()
|
|
@@ -60,13 +57,11 @@ test('Cloudflare WAF', async () => {
|
|
|
60
57
|
}).catch(() => null)
|
|
61
58
|
await new Promise(r => setTimeout(r, 2000));
|
|
62
59
|
}
|
|
63
|
-
await browser.close()
|
|
64
60
|
assert.strictEqual(verify === true, true, "Cloudflare WAF test failed! (Site may be blocking automated access)")
|
|
65
61
|
})
|
|
66
62
|
|
|
67
63
|
|
|
68
64
|
test('Cloudflare Turnstile', async () => {
|
|
69
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
70
65
|
await page.goto("https://2captcha.com/demo/cloudflare-turnstile");
|
|
71
66
|
await page.waitForSelector('.cf-turnstile')
|
|
72
67
|
let token = null
|
|
@@ -82,14 +77,11 @@ test('Cloudflare Turnstile', async () => {
|
|
|
82
77
|
})
|
|
83
78
|
await new Promise(r => setTimeout(r, 1000));
|
|
84
79
|
}
|
|
85
|
-
await browser.close()
|
|
86
|
-
// if (token !== null) console.log('Cloudflare Turnstile Token: ' + token);
|
|
87
80
|
assert.strictEqual(token !== null, true, "Cloudflare turnstile test failed!")
|
|
88
81
|
})
|
|
89
82
|
|
|
90
83
|
|
|
91
84
|
test('Fingerprint JS Bot Detector', async () => {
|
|
92
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
93
85
|
await page.goto("https://fingerprint.com/products/bot-detection/");
|
|
94
86
|
await new Promise(r => setTimeout(r, 8000));
|
|
95
87
|
const detect = await page.evaluate(() => {
|
|
@@ -111,30 +103,24 @@ test('Fingerprint JS Bot Detector', async () => {
|
|
|
111
103
|
}
|
|
112
104
|
return false;
|
|
113
105
|
})
|
|
114
|
-
await browser.close()
|
|
115
106
|
assert.strictEqual(detect, true, "Fingerprint JS Bot Detector test failed!")
|
|
116
107
|
})
|
|
117
108
|
|
|
118
109
|
|
|
119
110
|
// If you fail this test, your ip address probably has a high spam score. Please use a mobile or clean ip address.
|
|
120
111
|
test('Datadome Bot Detector', async (t) => {
|
|
121
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
122
112
|
await page.goto("https://antoinevastel.com/bots/datadome");
|
|
123
113
|
const check = await page.waitForSelector('nav #navbarCollapse').catch(() => null)
|
|
124
|
-
await browser.close()
|
|
125
114
|
assert.strictEqual(check ? true : false, true, "Datadome Bot Detector test failed! [This may also be because your ip address has a high spam score. Please try with a clean ip address.]")
|
|
126
115
|
})
|
|
127
116
|
|
|
128
117
|
// If this test fails, please first check if you can access https://antcpt.com/score_detector/
|
|
129
118
|
test('Recaptcha V3 Score (hard)', async () => {
|
|
130
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
131
119
|
await page.goto("https://antcpt.com/score_detector/");
|
|
132
120
|
await page.realClick("button")
|
|
133
121
|
await new Promise(r => setTimeout(r, 5000));
|
|
134
122
|
const score = await page.evaluate(() => {
|
|
135
123
|
return document.querySelector('big').textContent.replace(/[^0-9.]/g, '')
|
|
136
124
|
})
|
|
137
|
-
await browser.close()
|
|
138
|
-
// if (Number(score) >= 0.7) console.log('Recaptcha V3 Score: ' + score);
|
|
139
125
|
assert.strictEqual(Number(score) >= 0.7, true, "(please first check if you can access https://antcpt.com/score_detector/.) Recaptcha V3 Score (hard) should be >=0.7. Score Result: " + score)
|
|
140
126
|
})
|
package/test/esm/test.js
CHANGED
|
@@ -3,54 +3,49 @@ import assert from 'node:assert';
|
|
|
3
3
|
import { connect } from '../../lib/esm/index.mjs';
|
|
4
4
|
|
|
5
5
|
const realBrowserOption = {
|
|
6
|
-
args: ["--start-minimized"],
|
|
7
6
|
turnstile: true,
|
|
8
7
|
headless: false,
|
|
9
|
-
// disableXvfb: true,
|
|
10
|
-
// ignoreAllFlags:true,
|
|
11
8
|
customConfig: {},
|
|
12
|
-
connectOption: {
|
|
13
|
-
defaultViewport: null
|
|
14
|
-
},
|
|
15
9
|
plugins: []
|
|
16
10
|
}
|
|
17
11
|
|
|
12
|
+
// Shared browser instance for all tests
|
|
13
|
+
let browser = null;
|
|
14
|
+
let page = null;
|
|
18
15
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
// Setup - Run once before all tests
|
|
17
|
+
test.before(async () => {
|
|
18
|
+
console.log('🚀 Starting browser for all tests...');
|
|
19
|
+
const result = await connect(realBrowserOption);
|
|
20
|
+
browser = result.browser;
|
|
21
|
+
page = result.page;
|
|
22
|
+
console.log('✅ Browser started successfully');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Teardown - Run once after all tests
|
|
26
|
+
test.after(async () => {
|
|
27
|
+
console.log('🏁 Closing browser after all tests...');
|
|
28
|
+
if (browser) {
|
|
29
|
+
await browser.close();
|
|
30
|
+
console.log('✅ Browser closed successfully');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
33
|
|
|
34
34
|
test('DrissionPage Detector', async () => {
|
|
35
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
36
35
|
await page.goto("https://web.archive.org/web/20240913054632/https://drissionpage.pages.dev/");
|
|
37
36
|
await page.realClick("#detector")
|
|
38
37
|
let result = await page.evaluate(() => { return document.querySelector('#isBot span').textContent.includes("not") ? true : false })
|
|
39
|
-
await browser.close()
|
|
40
38
|
assert.strictEqual(result, true, "DrissionPage Detector test failed!")
|
|
41
39
|
})
|
|
42
40
|
|
|
43
41
|
test('Brotector, a webdriver detector', async () => {
|
|
44
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
45
42
|
await page.goto("https://kaliiiiiiiiii.github.io/brotector/");
|
|
46
43
|
await new Promise(r => setTimeout(r, 3000));
|
|
47
44
|
let result = await page.evaluate(() => { return document.querySelector('#table-keys').getAttribute('bgcolor') })
|
|
48
|
-
await browser.close()
|
|
49
45
|
assert.strictEqual(result === "darkgreen", true, "Brotector, a webdriver detector test failed!")
|
|
50
46
|
})
|
|
51
47
|
|
|
52
48
|
test('Cloudflare WAF', async () => {
|
|
53
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
54
49
|
await page.goto("https://nopecha.com/demo/cloudflare");
|
|
55
50
|
let verify = null
|
|
56
51
|
let startDate = Date.now()
|
|
@@ -62,13 +57,11 @@ test('Cloudflare WAF', async () => {
|
|
|
62
57
|
}).catch(() => null)
|
|
63
58
|
await new Promise(r => setTimeout(r, 2000));
|
|
64
59
|
}
|
|
65
|
-
await browser.close()
|
|
66
60
|
assert.strictEqual(verify === true, true, "Cloudflare WAF test failed! (Site may be blocking automated access)")
|
|
67
61
|
})
|
|
68
62
|
|
|
69
63
|
|
|
70
64
|
test('Cloudflare Turnstile', async () => {
|
|
71
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
72
65
|
await page.goto("https://2captcha.com/demo/cloudflare-turnstile");
|
|
73
66
|
await page.waitForSelector('.cf-turnstile')
|
|
74
67
|
let token = null
|
|
@@ -84,15 +77,12 @@ test('Cloudflare Turnstile', async () => {
|
|
|
84
77
|
})
|
|
85
78
|
await new Promise(r => setTimeout(r, 1000));
|
|
86
79
|
}
|
|
87
|
-
await browser.close()
|
|
88
|
-
// if (token !== null) console.log('Cloudflare Turnstile Token: ' + token);
|
|
89
80
|
assert.strictEqual(token !== null, true, "Cloudflare turnstile test failed!")
|
|
90
81
|
})
|
|
91
82
|
|
|
92
83
|
|
|
93
84
|
|
|
94
85
|
test('Fingerprint JS Bot Detector', async () => {
|
|
95
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
96
86
|
await page.goto("https://fingerprint.com/products/bot-detection/");
|
|
97
87
|
await new Promise(r => setTimeout(r, 8000));
|
|
98
88
|
const detect = await page.evaluate(() => {
|
|
@@ -114,30 +104,24 @@ test('Fingerprint JS Bot Detector', async () => {
|
|
|
114
104
|
}
|
|
115
105
|
return false;
|
|
116
106
|
})
|
|
117
|
-
await browser.close()
|
|
118
107
|
assert.strictEqual(detect, true, "Fingerprint JS Bot Detector test failed!")
|
|
119
108
|
})
|
|
120
109
|
|
|
121
110
|
|
|
122
111
|
// If you fail this test, your ip address probably has a high spam score. Please use a mobile or clean ip address.
|
|
123
112
|
test('Datadome Bot Detector', async (t) => {
|
|
124
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
125
113
|
await page.goto("https://antoinevastel.com/bots/datadome");
|
|
126
114
|
const check = await page.waitForSelector('nav #navbarCollapse').catch(() => null)
|
|
127
|
-
await browser.close()
|
|
128
115
|
assert.strictEqual(check ? true : false, true, "Datadome Bot Detector test failed! [This may also be because your ip address has a high spam score. Please try with a clean ip address.]")
|
|
129
116
|
})
|
|
130
117
|
|
|
131
118
|
// If this test fails, please first check if you can access https://antcpt.com/score_detector/
|
|
132
119
|
test('Recaptcha V3 Score (hard)', async () => {
|
|
133
|
-
const { page, browser } = await connect(realBrowserOption)
|
|
134
120
|
await page.goto("https://antcpt.com/score_detector/");
|
|
135
121
|
await page.realClick("button")
|
|
136
122
|
await new Promise(r => setTimeout(r, 5000));
|
|
137
123
|
const score = await page.evaluate(() => {
|
|
138
124
|
return document.querySelector('big').textContent.replace(/[^0-9.]/g, '')
|
|
139
125
|
})
|
|
140
|
-
await browser.close()
|
|
141
|
-
// if (Number(score) >= 0.7) console.log('Recaptcha V3 Score: ' + score);
|
|
142
126
|
assert.strictEqual(Number(score) >= 0.7, true, "(please first check if you can access https://antcpt.com/score_detector/.) Recaptcha V3 Score (hard) should be >=0.7. Score Result: " + score)
|
|
143
127
|
})
|