arn-browser 0.1.48 → 0.1.50
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 +3 -3
- package/src/utility/playwright/routes/pwRoute.d.ts +7 -0
- package/src/utility/playwright/routes/pwRoute.js +31 -0
- package/src/utility/proxy-utility/proxy-helper.js +2 -1
- package/src/utility/puppeteer/routes/ppRoute.d.ts +7 -0
- package/src/utility/puppeteer/routes/ppRoute.js +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arn-browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.50",
|
|
4
4
|
"description": "A lightweight, browser autmation helper.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@aws-sdk/client-ec2": "^3.1053.0",
|
|
16
16
|
"@ghostery/adblocker": "^2.17.3",
|
|
17
|
-
"arn-knexjs": "^0.0.
|
|
17
|
+
"arn-knexjs": "^0.0.7",
|
|
18
18
|
"camoufox-js": "^0.10.2",
|
|
19
19
|
"devtools-detector": "^2.0.25",
|
|
20
20
|
"dotenv": "^17.2.3",
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
"author": "ARNDESK",
|
|
45
45
|
"license": "ISC",
|
|
46
46
|
"type": "module"
|
|
47
|
-
}
|
|
47
|
+
}
|
|
@@ -63,6 +63,13 @@ export interface PwRouteOptions {
|
|
|
63
63
|
*/
|
|
64
64
|
skipGotPatterns?: string[];
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Array of hostnames to block. All request types to matching hosts are aborted.
|
|
68
|
+
* - Exact match: "ads.example.com" blocks only that exact hostname.
|
|
69
|
+
* - Substring match: "%google%" blocks any hostname containing "google".
|
|
70
|
+
*/
|
|
71
|
+
blockHosts?: string[];
|
|
72
|
+
|
|
66
73
|
/**
|
|
67
74
|
* Intercept XHR/Fetch requests.
|
|
68
75
|
* Can be boolean (true/false) or a custom proxy string/object used only for XHR/Fetch requests.
|
|
@@ -23,6 +23,7 @@ const DEFAULTS = {
|
|
|
23
23
|
m4w_send_on_message: null,
|
|
24
24
|
allowImagePatterns: [],
|
|
25
25
|
skipGotPatterns: [],
|
|
26
|
+
blockHosts: [],
|
|
26
27
|
xhr: false,
|
|
27
28
|
};
|
|
28
29
|
|
|
@@ -30,6 +31,20 @@ const DEFAULTS = {
|
|
|
30
31
|
* Helper to update derived configuration values from active user options.
|
|
31
32
|
*/
|
|
32
33
|
function updateDerivedConfig(config) {
|
|
34
|
+
// 0. Defaults/merges for blockHosts
|
|
35
|
+
const blockHosts = config.blockHosts || [];
|
|
36
|
+
config.finalBlockHostsExact = new Set();
|
|
37
|
+
config.finalBlockHostsContains = [];
|
|
38
|
+
for (const pattern of blockHosts) {
|
|
39
|
+
if (pattern.startsWith("%") && pattern.endsWith("%") && pattern.length > 2) {
|
|
40
|
+
// %pattern% → substring match against hostname
|
|
41
|
+
config.finalBlockHostsContains.push(pattern.slice(1, -1).toLowerCase());
|
|
42
|
+
} else {
|
|
43
|
+
// exact match against hostname
|
|
44
|
+
config.finalBlockHostsExact.add(pattern.toLowerCase());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
33
48
|
// 1. Defaults/merges for allowImagePatterns
|
|
34
49
|
const allowImagePatterns = config.allowImagePatterns || [];
|
|
35
50
|
config.finalImagePatterns = ["cdn-cgi/challenge-platform", ...allowImagePatterns];
|
|
@@ -376,6 +391,22 @@ export async function pwRoute(options = {}) {
|
|
|
376
391
|
const method = request.method();
|
|
377
392
|
const resourceType = request.resourceType();
|
|
378
393
|
|
|
394
|
+
// ============================================================
|
|
395
|
+
// Group 0: Host Blocking (blockHosts)
|
|
396
|
+
// ============================================================
|
|
397
|
+
if (currentConfig.finalBlockHostsExact.size > 0 || currentConfig.finalBlockHostsContains.length > 0) {
|
|
398
|
+
try {
|
|
399
|
+
const hostname = new URL(url).hostname.toLowerCase();
|
|
400
|
+
if (
|
|
401
|
+
currentConfig.finalBlockHostsExact.has(hostname) ||
|
|
402
|
+
currentConfig.finalBlockHostsContains.some((p) => hostname.includes(p))
|
|
403
|
+
) {
|
|
404
|
+
route.abort();
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
} catch {}
|
|
408
|
+
}
|
|
409
|
+
|
|
379
410
|
// ============================================================
|
|
380
411
|
// Group 1: Image Blocking
|
|
381
412
|
// ============================================================
|
|
@@ -56,7 +56,8 @@ export async function get_multilogin_proxy({
|
|
|
56
56
|
|
|
57
57
|
// 2. Prepare Data (sanitize region: spaces → underscores)
|
|
58
58
|
const sanitizedRegion = region ? region.toLowerCase().replace(/ /g, '_') : region;
|
|
59
|
-
const
|
|
59
|
+
const finalCountry = (country && country.toLowerCase() === "ww") ? "any" : country;
|
|
60
|
+
const data = { country: finalCountry, sessionType, protocol, region: sanitizedRegion, city, IPTTL, count: 1 };
|
|
60
61
|
Object.keys(data).forEach((k) => (data[k] === "" || data[k] === 0 || data[k] == null) && delete data[k]);
|
|
61
62
|
|
|
62
63
|
// 3. Setup Timeout
|
|
@@ -60,6 +60,13 @@ export interface PpRouteOptions {
|
|
|
60
60
|
*/
|
|
61
61
|
skipGotPatterns?: string[];
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Array of hostnames to block. All request types to matching hosts are aborted.
|
|
65
|
+
* - Exact match: "ads.example.com" blocks only that exact hostname.
|
|
66
|
+
* - Substring match: "%google%" blocks any hostname containing "google".
|
|
67
|
+
*/
|
|
68
|
+
blockHosts?: string[];
|
|
69
|
+
|
|
63
70
|
/**
|
|
64
71
|
* Intercept XHR/Fetch requests.
|
|
65
72
|
* Can be boolean (true/false) or a custom proxy string/object used only for XHR/Fetch requests.
|
|
@@ -23,6 +23,7 @@ const DEFAULTS = {
|
|
|
23
23
|
m4w_send_on_message: null,
|
|
24
24
|
allowImagePatterns: [],
|
|
25
25
|
skipGotPatterns: [],
|
|
26
|
+
blockHosts: [],
|
|
26
27
|
xhr: false,
|
|
27
28
|
};
|
|
28
29
|
|
|
@@ -30,6 +31,20 @@ const DEFAULTS = {
|
|
|
30
31
|
* Helper to update derived configuration values from active user options.
|
|
31
32
|
*/
|
|
32
33
|
function updateDerivedConfig(config) {
|
|
34
|
+
// 0. Defaults/merges for blockHosts
|
|
35
|
+
const blockHosts = config.blockHosts || [];
|
|
36
|
+
config.finalBlockHostsExact = new Set();
|
|
37
|
+
config.finalBlockHostsContains = [];
|
|
38
|
+
for (const pattern of blockHosts) {
|
|
39
|
+
if (pattern.startsWith("%") && pattern.endsWith("%") && pattern.length > 2) {
|
|
40
|
+
// %pattern% → substring match against hostname
|
|
41
|
+
config.finalBlockHostsContains.push(pattern.slice(1, -1).toLowerCase());
|
|
42
|
+
} else {
|
|
43
|
+
// exact match against hostname
|
|
44
|
+
config.finalBlockHostsExact.add(pattern.toLowerCase());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
33
48
|
// 1. Defaults/merges for allowImagePatterns
|
|
34
49
|
const allowImagePatterns = config.allowImagePatterns || [];
|
|
35
50
|
config.finalImagePatterns = ["cdn-cgi/challenge-platform", ...allowImagePatterns];
|
|
@@ -383,6 +398,22 @@ export async function ppRoute(options = {}) {
|
|
|
383
398
|
const method = request.method();
|
|
384
399
|
const resourceType = request.resourceType();
|
|
385
400
|
|
|
401
|
+
// ============================================================
|
|
402
|
+
// Group 0: Host Blocking (blockHosts)
|
|
403
|
+
// ============================================================
|
|
404
|
+
if (currentConfig.finalBlockHostsExact.size > 0 || currentConfig.finalBlockHostsContains.length > 0) {
|
|
405
|
+
try {
|
|
406
|
+
const hostname = new URL(url).hostname.toLowerCase();
|
|
407
|
+
if (
|
|
408
|
+
currentConfig.finalBlockHostsExact.has(hostname) ||
|
|
409
|
+
currentConfig.finalBlockHostsContains.some((p) => hostname.includes(p))
|
|
410
|
+
) {
|
|
411
|
+
await request.abort();
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
} catch {}
|
|
415
|
+
}
|
|
416
|
+
|
|
386
417
|
// ============================================================
|
|
387
418
|
// Group 1: Image Blocking
|
|
388
419
|
// ============================================================
|