@fanboynz/network-scanner 2.0.11 → 2.0.12
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/fingerprint.js +44 -15
- package/nwss.js +3 -3
- package/package.json +1 -1
package/lib/fingerprint.js
CHANGED
|
@@ -180,7 +180,7 @@ async function validatePageForInjection(page, currentUrl, forceDebug) {
|
|
|
180
180
|
try {
|
|
181
181
|
if (page.isClosed()) return false;
|
|
182
182
|
await Promise.race([
|
|
183
|
-
page.evaluate(() => document.readyState),
|
|
183
|
+
page.evaluate(() => document.readyState || 'loading'),
|
|
184
184
|
new Promise((_, reject) => setTimeout(() => reject(new Error('Page unresponsive')), 3000))
|
|
185
185
|
]);
|
|
186
186
|
return true;
|
|
@@ -268,6 +268,12 @@ async function applyUserAgentSpoofing(page, siteConfig, forceDebug, currentUrl)
|
|
|
268
268
|
|
|
269
269
|
if (forceDebug) console.log(`[debug] User agent spoofing: ${siteConfig.userAgent}`);
|
|
270
270
|
|
|
271
|
+
// Browser connection check
|
|
272
|
+
try {
|
|
273
|
+
if (!page.browser().isConnected() || page.isClosed()) return;
|
|
274
|
+
if (page.browser().process()?.killed) return;
|
|
275
|
+
} catch { return; }
|
|
276
|
+
|
|
271
277
|
// Validate page state before injection
|
|
272
278
|
if (!(await validatePageForInjection(page, currentUrl, forceDebug))) return;
|
|
273
279
|
|
|
@@ -682,7 +688,11 @@ async function applyUserAgentSpoofing(page, siteConfig, forceDebug, currentUrl)
|
|
|
682
688
|
} catch (stealthErr) {
|
|
683
689
|
if (stealthErr.message.includes('Session closed') ||
|
|
684
690
|
stealthErr.message.includes('addScriptToEvaluateOnNewDocument timed out') ||
|
|
685
|
-
stealthErr.message.includes('Target closed')
|
|
691
|
+
stealthErr.message.includes('Target closed') ||
|
|
692
|
+
stealthErr.message.includes('Protocol error') || stealthErr.name === 'ProtocolError' ||
|
|
693
|
+
stealthErr.message.includes('detached Frame') || stealthErr.message.includes('Navigating frame was detached') ||
|
|
694
|
+
stealthErr.message.includes('Cannot find context') ||
|
|
695
|
+
stealthErr.message.includes('Execution context was destroyed')) {
|
|
686
696
|
if (forceDebug) console.log(`[debug] Page closed during stealth injection: ${currentUrl}`);
|
|
687
697
|
return;
|
|
688
698
|
}
|
|
@@ -698,24 +708,19 @@ async function applyBraveSpoofing(page, siteConfig, forceDebug, currentUrl) {
|
|
|
698
708
|
if (!siteConfig.isBrave) return;
|
|
699
709
|
|
|
700
710
|
if (forceDebug) console.log(`[debug] Brave spoofing enabled for ${currentUrl}`);
|
|
711
|
+
|
|
712
|
+
// Browser connection check
|
|
713
|
+
try {
|
|
714
|
+
if (!page.browser().isConnected() || page.isClosed()) return;
|
|
715
|
+
if (page.browser().process()?.killed) return;
|
|
716
|
+
} catch { return; }
|
|
701
717
|
|
|
702
718
|
// Validate page state before injection
|
|
703
719
|
if (!(await validatePageForInjection(page, currentUrl, forceDebug))) return;
|
|
704
720
|
|
|
705
721
|
try {
|
|
706
722
|
await page.evaluateOnNewDocument((debugEnabled) => {
|
|
707
|
-
|
|
708
|
-
}, forceDebug);
|
|
709
|
-
} catch (braveErr) {
|
|
710
|
-
if (braveErr.message.includes('Session closed') ||
|
|
711
|
-
braveErr.message.includes('addScriptToEvaluateOnNewDocument timed out') ||
|
|
712
|
-
braveErr.message.includes('Target closed')) {
|
|
713
|
-
if (forceDebug) console.log(`[debug] Page closed during Brave injection: ${currentUrl}`);
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
if (forceDebug) console.log(`[debug] Brave spoofing failed: ${currentUrl} - ${braveErr.message}`);
|
|
717
|
-
}
|
|
718
|
-
try {
|
|
723
|
+
try {
|
|
719
724
|
Object.defineProperty(navigator, 'brave', {
|
|
720
725
|
get: () => ({
|
|
721
726
|
isBrave: () => Promise.resolve(true),
|
|
@@ -736,6 +741,20 @@ async function applyBraveSpoofing(page, siteConfig, forceDebug, currentUrl) {
|
|
|
736
741
|
} catch (err) {
|
|
737
742
|
if (debugEnabled) console.log(`[fingerprint] Brave spoofing error: ${err.message}`);
|
|
738
743
|
}
|
|
744
|
+
}, forceDebug);
|
|
745
|
+
} catch (braveErr) {
|
|
746
|
+
if (braveErr.message.includes('Session closed') ||
|
|
747
|
+
braveErr.message.includes('addScriptToEvaluateOnNewDocument timed out') ||
|
|
748
|
+
braveErr.message.includes('Target closed') ||
|
|
749
|
+
braveErr.message.includes('Protocol error') || braveErr.name === 'ProtocolError' ||
|
|
750
|
+
braveErr.message.includes('detached Frame') || braveErr.message.includes('Navigating frame was detached') ||
|
|
751
|
+
braveErr.message.includes('Cannot find context') ||
|
|
752
|
+
braveErr.message.includes('Execution context was destroyed')) {
|
|
753
|
+
if (forceDebug) console.log(`[debug] Page closed during Brave injection: ${currentUrl}`);
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
if (forceDebug) console.log(`[debug] Brave spoofing failed: ${currentUrl} - ${braveErr.message}`);
|
|
757
|
+
}
|
|
739
758
|
}
|
|
740
759
|
|
|
741
760
|
/**
|
|
@@ -747,6 +766,12 @@ async function applyFingerprintProtection(page, siteConfig, forceDebug, currentU
|
|
|
747
766
|
|
|
748
767
|
if (forceDebug) console.log(`[debug] Fingerprint protection enabled for ${currentUrl}`);
|
|
749
768
|
|
|
769
|
+
// Browser connection check
|
|
770
|
+
try {
|
|
771
|
+
if (!page.browser().isConnected() || page.isClosed()) return;
|
|
772
|
+
if (page.browser().process()?.killed) return;
|
|
773
|
+
} catch { return; }
|
|
774
|
+
|
|
750
775
|
// Validate page state before injection
|
|
751
776
|
if (!(await validatePageForInjection(page, currentUrl, forceDebug))) return;
|
|
752
777
|
|
|
@@ -841,7 +866,11 @@ async function applyFingerprintProtection(page, siteConfig, forceDebug, currentU
|
|
|
841
866
|
} catch (err) {
|
|
842
867
|
if (err.message.includes('Session closed') ||
|
|
843
868
|
err.message.includes('addScriptToEvaluateOnNewDocument timed out') ||
|
|
844
|
-
err.message.includes('Target closed')
|
|
869
|
+
err.message.includes('Target closed') ||
|
|
870
|
+
err.message.includes('Protocol error') || err.name === 'ProtocolError' ||
|
|
871
|
+
err.message.includes('detached Frame') || err.message.includes('Navigating frame was detached') ||
|
|
872
|
+
err.message.includes('Cannot find context') ||
|
|
873
|
+
err.message.includes('Execution context was destroyed')) {
|
|
845
874
|
if (forceDebug) console.log(`[debug] Page closed during fingerprint injection: ${currentUrl}`);
|
|
846
875
|
return;
|
|
847
876
|
}
|
package/nwss.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// === Network scanner script (nwss.js) v2.0.
|
|
1
|
+
// === Network scanner script (nwss.js) v2.0.12 ===
|
|
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
|
|
@@ -130,7 +130,7 @@ const { navigateWithRedirectHandling, handleRedirectTimeout } = require('./lib/r
|
|
|
130
130
|
const { monitorBrowserHealth, isBrowserHealthy, isQuicklyResponsive, performGroupWindowCleanup, performRealtimeWindowCleanup, trackPageForRealtime, updatePageUsage, cleanupPageBeforeReload } = require('./lib/browserhealth');
|
|
131
131
|
|
|
132
132
|
// --- Script Configuration & Constants ---
|
|
133
|
-
const VERSION = '2.0.
|
|
133
|
+
const VERSION = '2.0.12'; // Script version
|
|
134
134
|
|
|
135
135
|
// get startTime
|
|
136
136
|
const startTime = Date.now();
|
|
@@ -3993,4 +3993,4 @@ function setupFrameHandling(page, forceDebug) {
|
|
|
3993
3993
|
if (forceDebug) console.log(formatLogMessage('debug', `About to exit process...`));
|
|
3994
3994
|
process.exit(0);
|
|
3995
3995
|
|
|
3996
|
-
})();
|
|
3996
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fanboynz/network-scanner",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
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": {
|