@fanboynz/network-scanner 2.0.5 → 2.0.6
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/cdp.js +31 -6
- package/nwss.js +6 -3
- package/package.json +1 -1
package/lib/cdp.js
CHANGED
|
@@ -49,12 +49,37 @@ async function createPageWithTimeout(browser, timeout = 30000) {
|
|
|
49
49
|
* @returns {Promise<void>}
|
|
50
50
|
*/
|
|
51
51
|
async function setRequestInterceptionWithTimeout(page, timeout = 15000) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
try {
|
|
53
|
+
await Promise.race([
|
|
54
|
+
page.setRequestInterception(true),
|
|
55
|
+
new Promise((_, reject) =>
|
|
56
|
+
setTimeout(() => reject(new Error('Request interception timeout - first attempt')), timeout)
|
|
57
|
+
)
|
|
58
|
+
]);
|
|
59
|
+
} catch (firstError) {
|
|
60
|
+
// Check for immediate critical failures
|
|
61
|
+
if (firstError.message.includes('Target closed') ||
|
|
62
|
+
firstError.message.includes('Session closed') ||
|
|
63
|
+
firstError.message.includes('Browser has been closed')) {
|
|
64
|
+
throw new Error('CRITICAL_BROWSER_ERROR: ' + firstError.message);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Retry with extended timeout
|
|
68
|
+
try {
|
|
69
|
+
await Promise.race([
|
|
70
|
+
page.setRequestInterception(true),
|
|
71
|
+
new Promise((_, reject) =>
|
|
72
|
+
setTimeout(() => reject(new Error('Request interception timeout - retry failed')), timeout * 2)
|
|
73
|
+
)
|
|
74
|
+
]);
|
|
75
|
+
} catch (retryError) {
|
|
76
|
+
if (retryError.message.includes('Network.enable timed out') ||
|
|
77
|
+
retryError.message.includes('ProtocolError')) {
|
|
78
|
+
throw new Error('CRITICAL_NETWORK_ERROR: ' + retryError.message);
|
|
79
|
+
}
|
|
80
|
+
throw retryError;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
58
83
|
}
|
|
59
84
|
|
|
60
85
|
/**
|
package/nwss.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// === Network scanner script (nwss.js) v2.0.
|
|
1
|
+
// === Network scanner script (nwss.js) v2.0.6 ===
|
|
2
2
|
|
|
3
3
|
// puppeteer for browser automation, fs for file system operations, psl for domain parsing.
|
|
4
4
|
// const pLimit = require('p-limit'); // Will be dynamically imported
|
|
@@ -127,7 +127,7 @@ const { navigateWithRedirectHandling, handleRedirectTimeout } = require('./lib/r
|
|
|
127
127
|
const { monitorBrowserHealth, isBrowserHealthy, isQuicklyResponsive, performGroupWindowCleanup, performRealtimeWindowCleanup, trackPageForRealtime, updatePageUsage } = require('./lib/browserhealth');
|
|
128
128
|
|
|
129
129
|
// --- Script Configuration & Constants ---
|
|
130
|
-
const VERSION = '2.0.
|
|
130
|
+
const VERSION = '2.0.6'; // Script version
|
|
131
131
|
|
|
132
132
|
// get startTime
|
|
133
133
|
const startTime = Date.now();
|
|
@@ -1903,7 +1903,10 @@ function setupFrameHandling(page, forceDebug) {
|
|
|
1903
1903
|
console.log(formatLogMessage('debug', `Request interception enabled successfully for ${currentUrl}`));
|
|
1904
1904
|
}
|
|
1905
1905
|
} catch (networkErr) {
|
|
1906
|
-
if (networkErr.message.includes('
|
|
1906
|
+
if (networkErr.message.includes('CRITICAL_NETWORK_ERROR') ||
|
|
1907
|
+
networkErr.message.includes('CRITICAL_BROWSER_ERROR') ||
|
|
1908
|
+
networkErr.message.includes('ProtocolError') ||
|
|
1909
|
+
networkErr.message.includes('timed out') ||
|
|
1907
1910
|
networkErr.message.includes('Network.enable') ||
|
|
1908
1911
|
networkErr.message.includes('timeout')) {
|
|
1909
1912
|
console.warn(formatLogMessage('warn', `Request interception setup failed for ${currentUrl}: ${networkErr.message} - triggering browser restart`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fanboynz/network-scanner",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "A Puppeteer-based network scanner for analyzing web traffic, generating adblock filter rules, and identifying third-party requests. Features include fingerprint spoofing, Cloudflare bypass, content analysis with curl/grep, and multiple output formats.",
|
|
5
5
|
"main": "nwss.js",
|
|
6
6
|
"scripts": {
|