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.
Files changed (3) hide show
  1. package/README.md +99 -74
  2. package/index.js +67 -71
  3. package/package.json +3 -4
package/README.md CHANGED
@@ -1,74 +1,99 @@
1
- # Usage
2
- ## 1 - First let's start by installing the module
3
- ```
4
- npm install antibotbrowser
5
-
6
- ```
7
-
8
- ## 2 - Let's include our module in our project
9
- ```js
10
- const antibotbrowser = require("antibotbrowser");
11
- ```
12
-
13
- ## 3 - And let's run our browser
14
- ```js
15
- var antibrowser = await antibotbrowser.startbrowser(9222);
16
- //OR HİDE MOD (headless / no-sandbox) Mode Open browser
17
- var antibrowser = await antibotbrowser.startbrowser_hide(9222);
18
- ```
19
-
20
- ## END - Connect the browser to puppeteer with websocket
21
- ```js
22
- const antibotbrowser = require("antibotbrowser");
23
- const puppeteer = require('puppeteer');
24
-
25
- (async () => {
26
-
27
- const antibrowser = await antibotbrowser.startbrowser(9222);
28
-
29
- const browser = await puppeteer.connect({browserWSEndpoint: antibrowser.websokcet});
30
-
31
- // Normal use from now on
32
- const page = await browser.newPage();
33
-
34
- await page.setViewport({width:0, height:0});
35
-
36
- page.goto("https://google.com")
37
-
38
- })();
39
-
40
- ```
41
-
42
- ## Example uses
43
- 1-
44
- ```js
45
- const antibotbrowser = require("antibotbrowser");
46
- const puppeteer = require('puppeteer');
47
- (async () => {
48
-
49
- const antibrowser = await antibotbrowser.startbrowser(); // We start the browser with default settings. Port: 9222 Url: google.com
50
-
51
- const browser = await puppeteer.connect({browserWSEndpoint: antibrowser.websokcet}); // We connect the launched browser to puppeteer. With the variable we created above, it gives the web socket url to puppetter with antibotbrowser.websocket .
52
-
53
- // Normal use from now on
54
- const page = await browser.newPage();
55
-
56
- await page.setViewport({width:0, height:0});
57
-
58
- page.goto("https://google.com")
59
-
60
- })();
61
- ```
62
-
63
- ## Arguments
64
- ```js
65
- antibotbrowser.startbrowser(port, url);
66
- // port: The debugging port is the debugging port of the chromium browser. There can be 1 browser on the same port number, so you can add it as an argument. By default, if you enter nothing, the port is 9222.
67
-
68
- // url: The first page address on browser startup. If you leave it blank, it defaults to google.com.
69
-
70
- // Examples
71
- antibotbrowser.startbrowser(9223, "https://github.com");
72
- antibotbrowser.startbrowser(9222, "https://google.com");
73
- // note do not start 2 scanners on the same port!!!
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
- var request = require('sync-request');
4
- const fs = require('fs');
5
- const { start } = require('repl');
6
-
7
- // github.com/reloxe
8
- // nokersoft.com
9
-
10
- versioncehck();
11
- async function versioncehck() {
12
- var versioncheck = await request('GET', `https://registry.npmjs.org/antibotbrowser/latest`);
13
- if (JSON.parse(versioncheck.getBody())['version'] != JSON.parse(fs.readFileSync(__dirname + '/package.json'))['version']) {
14
- console.log("[Notification] AntiBotBrowser New Version Available !");
15
- }
16
- }
17
-
18
-
19
- const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
20
-
21
- async function startbrowser_hide(port) {
22
- return new Promise(async(resolve, reject) => {
23
-
24
- try {
25
-
26
- execFile(chromium.path, ['--remote-debugging-port=' + port, '--headless', '--no-sandbox'], (err) => {
27
- if (err) { }
28
- });
29
- await delay(4000);
30
- var res = await request('GET', `http://127.0.0.1:${port}/json/version`);
31
- veri = await JSON.parse(res.getBody())
32
- useragent = await veri["User-Agent"];
33
- websokcet = await veri["webSocketDebuggerUrl"];
34
-
35
- resolve( { useragent, websokcet } )
36
-
37
- } catch (error) {
38
- startbrowser_hide(port);
39
- }
40
-
41
- })
42
- }
43
-
44
-
45
- async function startbrowser(port) {
46
- return new Promise(async(resolve, reject) => {
47
-
48
- try {
49
-
50
- execFile(chromium.path, ['--remote-debugging-port=' + port], (err) => {
51
- if (err) { }
52
- });
53
- await delay(4000);
54
- var res = await request('GET', `http://127.0.0.1:${port}/json/version`);
55
- veri = await JSON.parse(res.getBody())
56
- useragent = await veri["User-Agent"];
57
- websokcet = await veri["webSocketDebuggerUrl"];
58
-
59
- resolve( { useragent, websokcet } )
60
-
61
-
62
- } catch (error) {
63
- startbrowser(port);
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": "1.0.9",
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": "^3.0.3",
14
- "sync-request": "^6.1.0"
13
+ "chromium": "3.0.3"
15
14
  }
16
- }
15
+ }