antibotbrowser 1.0.9 → 3.0.0
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/README.md +99 -74
- package/index.js +67 -71
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,74 +1,99 @@
|
|
|
1
|
-
# Usage
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
```
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
1
|
+
# Usage
|
|
2
|
+
> This library is designed to behave like a real browser, allowing you to bypass **Cloudflare Challenges** and other bot verification systems that often block traditional automated tools.
|
|
3
|
+
> This is for educational purposes only. Bypassing systems like bot verification may be illegal. User responsibility lies with the user.
|
|
4
|
+
> **Note:** This package is compatible with **Puppeteer**, **Playwright**, and any other automation framework that supports the Chrome DevTools Protocol (CDP).
|
|
5
|
+
## 1 - First let's start by installing the module
|
|
6
|
+
```
|
|
7
|
+
npm install antibotbrowser
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## 2 - Let's include our module in our project
|
|
11
|
+
```js
|
|
12
|
+
const antibotbrowser = require("antibotbrowser");
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 3 - And let's run our browser
|
|
16
|
+
```js
|
|
17
|
+
// Default use (Port: 9222)
|
|
18
|
+
var antibrowser = await antibotbrowser.startbrowser(9222);
|
|
19
|
+
|
|
20
|
+
// Advanced use with options
|
|
21
|
+
var antibrowser = await antibotbrowser.startbrowser({
|
|
22
|
+
port: 9222, // Default: 9222 (Optional)
|
|
23
|
+
userdata: true, // persistent profile (Default: true) (Optional)
|
|
24
|
+
headless: true, // headless mode (Default: false) (Optional)
|
|
25
|
+
nosandbox: true // no-sandbox mode (Default: false) (Optional)
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> If `userdata` is `true`, the browser will use a persistent profile to save your session (cookies, history, etc.). If `false`, it will use a temporary profile that is deleted when the browser is closed.
|
|
30
|
+
|
|
31
|
+
## END - Connect the browser to puppeteer with websocket
|
|
32
|
+
```js
|
|
33
|
+
const antibotbrowser = require("antibotbrowser");
|
|
34
|
+
const puppeteer = require('puppeteer');
|
|
35
|
+
|
|
36
|
+
(async () => {
|
|
37
|
+
|
|
38
|
+
const antibrowser = await antibotbrowser.startbrowser({
|
|
39
|
+
port: 9222,
|
|
40
|
+
headless: false
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const browser = await puppeteer.connect({browserWSEndpoint: antibrowser.websokcet});
|
|
44
|
+
|
|
45
|
+
// Normal use from now on
|
|
46
|
+
const page = await browser.newPage();
|
|
47
|
+
|
|
48
|
+
await page.setViewport({width:0, height:0});
|
|
49
|
+
|
|
50
|
+
await page.goto("https://www.nokersoft.com")
|
|
51
|
+
|
|
52
|
+
})();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Example uses
|
|
56
|
+
```js
|
|
57
|
+
const antibotbrowser = require("antibotbrowser");
|
|
58
|
+
const puppeteer = require('puppeteer');
|
|
59
|
+
(async () => {
|
|
60
|
+
|
|
61
|
+
const antibrowser = await antibotbrowser.startbrowser(9222); // We start the browser with settings Port: 9222
|
|
62
|
+
|
|
63
|
+
const browser = await puppeteer.connect({browserWSEndpoint: antibrowser.websokcet}); // We connect the launched browser to puppeteer.
|
|
64
|
+
|
|
65
|
+
// Normal use from now on
|
|
66
|
+
const page = await browser.newPage();
|
|
67
|
+
|
|
68
|
+
await page.setViewport({width:0, height:0});
|
|
69
|
+
|
|
70
|
+
await page.goto("https://www.nokersoft.com")
|
|
71
|
+
|
|
72
|
+
})();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Troubleshooting and General Information
|
|
76
|
+
- **Linux / Server Usage:** If you are running on a Linux server without a GUI (e.g., Ubuntu Server), you must use the `headless: true` option.
|
|
77
|
+
- **Root User:** If you are running the script as a `root` user, Chromium may fail to start due to security restrictions. In this case, use the `nosandbox: true` option.
|
|
78
|
+
- **Port Conflicts:** If the default port `9222` is already in use by another application, you can specify a different port using the `port` option (e.g., `9333`).
|
|
79
|
+
- **Dependencies:** Ensure that your system has the necessary dependencies installed for Chromium to run (especially on minimal Linux distributions).
|
|
80
|
+
|
|
81
|
+
### Usage with Playwright
|
|
82
|
+
```js
|
|
83
|
+
const { chromium } = require('playwright');
|
|
84
|
+
const antibotbrowser = require("antibotbrowser");
|
|
85
|
+
|
|
86
|
+
(async () => {
|
|
87
|
+
const antibrowser = await antibotbrowser.startbrowser(9222);
|
|
88
|
+
|
|
89
|
+
// Connect Playwright to the launched browser via CDP
|
|
90
|
+
const browser = await chromium.connectOverCDP(`http://localhost:9222`);
|
|
91
|
+
|
|
92
|
+
const context = browser.contexts()[0];
|
|
93
|
+
const page = context.pages()[0] || await context.newPage();
|
|
94
|
+
|
|
95
|
+
await page.goto("https://www.nokersoft.com");
|
|
96
|
+
|
|
97
|
+
console.log("Page title:", await page.title());
|
|
98
|
+
})();
|
|
99
|
+
```
|
package/index.js
CHANGED
|
@@ -1,72 +1,68 @@
|
|
|
1
|
-
const chromium = require('chromium');
|
|
2
|
-
const {execFile} = require('child_process');
|
|
3
|
-
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
module.exports = {
|
|
70
|
-
startbrowser_hide,
|
|
71
|
-
startbrowser
|
|
1
|
+
const chromium = require('chromium');
|
|
2
|
+
const { execFile } = require('child_process');
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
// github.com/reloxe
|
|
9
|
+
// nokersoft.com
|
|
10
|
+
|
|
11
|
+
versioncehck();
|
|
12
|
+
async function versioncehck() {
|
|
13
|
+
try {
|
|
14
|
+
var versioncheck = await fetch(`https://registry.npmjs.org/antibotbrowser/latest`);
|
|
15
|
+
var versionBody = await versioncheck.text();
|
|
16
|
+
if (JSON.parse(versionBody)['version'] != JSON.parse(fs.readFileSync(__dirname + '/package.json'))['version']) {
|
|
17
|
+
console.log("[Notification] AntiBotBrowser New Version Available !");
|
|
18
|
+
}
|
|
19
|
+
} catch (e) { }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
|
|
23
|
+
|
|
24
|
+
async function startbrowser(options) {
|
|
25
|
+
const port = (typeof options === 'object' ? options.port : options) || 9222;
|
|
26
|
+
const userdata = (typeof options === 'object' ? options.userdata : false) || false;
|
|
27
|
+
const headless = (typeof options === 'object' ? options.headless : false) || false;
|
|
28
|
+
const nosandbox = (typeof options === 'object' ? options.nosandbox : false) || false;
|
|
29
|
+
|
|
30
|
+
const profileName = userdata ? `antibot_profile_persistent` : `antibot_profile_${Date.now()}`;
|
|
31
|
+
const baseDir = path.join(__dirname, 'antibot_profiles');
|
|
32
|
+
if (!fs.existsSync(baseDir)) {
|
|
33
|
+
fs.mkdirSync(baseDir, { recursive: true });
|
|
34
|
+
}
|
|
35
|
+
const tempProfile = path.join(baseDir, profileName);
|
|
36
|
+
|
|
37
|
+
var args = [
|
|
38
|
+
'--remote-debugging-port=' + port,
|
|
39
|
+
'--user-data-dir=' + tempProfile
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
if (headless) { args.push('--headless'); }
|
|
43
|
+
if (nosandbox) { args.push('--no-sandbox'); }
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
execFile(chromium.path, args, (err) => {
|
|
47
|
+
if (err) { }
|
|
48
|
+
});
|
|
49
|
+
} catch (e) { }
|
|
50
|
+
|
|
51
|
+
while (true) {
|
|
52
|
+
try {
|
|
53
|
+
var res = await fetch(`http://127.0.0.1:${port}/json/version`);
|
|
54
|
+
if (res.status === 200) {
|
|
55
|
+
var resBody = await res.text();
|
|
56
|
+
var veri = JSON.parse(resBody);
|
|
57
|
+
var useragent = veri["User-Agent"];
|
|
58
|
+
var websokcet = veri["webSocketDebuggerUrl"];
|
|
59
|
+
return { useragent, websokcet };
|
|
60
|
+
}
|
|
61
|
+
} catch (error) { }
|
|
62
|
+
await delay(300);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = {
|
|
67
|
+
startbrowser
|
|
72
68
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antibotbrowser",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"readme": "README.md",
|
|
5
5
|
"description": "Opening Chromium opens a real browser without bot validations in automated systems like Puppetter. To avoid problems in places like Cloudflare",
|
|
6
6
|
"main": "index.js",
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"author": "By Nokersoftware | nokersoft.com",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"chromium": "
|
|
14
|
-
"sync-request": "^6.1.0"
|
|
13
|
+
"chromium": "3.0.3"
|
|
15
14
|
}
|
|
16
|
-
}
|
|
15
|
+
}
|