@fanboynz/network-scanner 1.0.82 → 1.0.83
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/nwss.js +52 -41
- package/package.json +1 -1
package/nwss.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// === Network scanner script (nwss.js) v1.0.
|
|
1
|
+
// === Network scanner script (nwss.js) v1.0.83 ===
|
|
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
|
|
@@ -123,7 +123,7 @@ const { navigateWithRedirectHandling, handleRedirectTimeout } = require('./lib/r
|
|
|
123
123
|
const { monitorBrowserHealth, isBrowserHealthy } = require('./lib/browserhealth');
|
|
124
124
|
|
|
125
125
|
// --- Script Configuration & Constants ---
|
|
126
|
-
const VERSION = '1.0.
|
|
126
|
+
const VERSION = '1.0.83'; // Script version
|
|
127
127
|
|
|
128
128
|
// get startTime
|
|
129
129
|
const startTime = Date.now();
|
|
@@ -1375,8 +1375,8 @@ function setupFrameHandling(page, forceDebug) {
|
|
|
1375
1375
|
* @returns {Promise<object>} A promise that resolves to an object containing scan results.
|
|
1376
1376
|
*/
|
|
1377
1377
|
async function processUrl(currentUrl, siteConfig, browserInstance) {
|
|
1378
|
-
const allowFirstParty = siteConfig.firstParty === 1;
|
|
1379
|
-
const allowThirdParty = siteConfig.thirdParty === undefined || siteConfig.thirdParty === 1;
|
|
1378
|
+
const allowFirstParty = siteConfig.firstParty === true || siteConfig.firstParty === 1;
|
|
1379
|
+
const allowThirdParty = siteConfig.thirdParty === undefined || siteConfig.thirdParty === true || siteConfig.thirdParty === 1;
|
|
1380
1380
|
const perSiteSubDomains = siteConfig.subDomains === 1 ? true : subDomainsMode;
|
|
1381
1381
|
const siteLocalhost = siteConfig.localhost === true;
|
|
1382
1382
|
const siteLocalhostAlt = siteConfig.localhost_0_0_0_0 === true;
|
|
@@ -2172,7 +2172,7 @@ function setupFrameHandling(page, forceDebug) {
|
|
|
2172
2172
|
}
|
|
2173
2173
|
|
|
2174
2174
|
// Check party filtering AFTER regex match but BEFORE domain processing
|
|
2175
|
-
if (isFirstParty && siteConfig.firstParty === false) {
|
|
2175
|
+
if (isFirstParty && (siteConfig.firstParty === false || siteConfig.firstParty === 0)) {
|
|
2176
2176
|
if (forceDebug) {
|
|
2177
2177
|
console.log(formatLogMessage('debug', `Skipping first-party match: ${reqUrl} (firstParty disabled)`));
|
|
2178
2178
|
}
|
|
@@ -2180,7 +2180,7 @@ function setupFrameHandling(page, forceDebug) {
|
|
|
2180
2180
|
request.continue();
|
|
2181
2181
|
return;
|
|
2182
2182
|
}
|
|
2183
|
-
if (!isFirstParty && siteConfig.thirdParty === false) {
|
|
2183
|
+
if (!isFirstParty && (siteConfig.thirdParty === false || siteConfig.thirdParty === 0)) {
|
|
2184
2184
|
if (forceDebug) {
|
|
2185
2185
|
console.log(formatLogMessage('debug', `Skipping third-party match: ${reqUrl} (thirdParty disabled)`));
|
|
2186
2186
|
}
|
|
@@ -2812,43 +2812,54 @@ function setupFrameHandling(page, forceDebug) {
|
|
|
2812
2812
|
|
|
2813
2813
|
// Use fast timeout helper for consistent Puppeteer 23.x compatibility
|
|
2814
2814
|
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
await reloadClearSession.send('Network.clearBrowserCookies');
|
|
2822
|
-
await reloadClearSession.send('Network.clearBrowserCache');
|
|
2823
|
-
} finally {
|
|
2824
|
-
if (reloadClearSession) {
|
|
2825
|
-
try { await reloadClearSession.detach(); } catch (detachErr) { /* ignore */ }
|
|
2826
|
-
}
|
|
2827
|
-
}
|
|
2828
|
-
await page.evaluate(() => {
|
|
2829
|
-
localStorage.clear();
|
|
2830
|
-
sessionStorage.clear();
|
|
2831
|
-
indexedDB.databases().then(dbs => dbs.forEach(db => indexedDB.deleteDatabase(db.name)));
|
|
2832
|
-
});
|
|
2833
|
-
if (forceDebug) console.log(formatLogMessage('debug', `Cleared site data before reload #${i + 1} for ${currentUrl}`));
|
|
2834
|
-
} catch (reloadClearErr) {
|
|
2835
|
-
console.warn(messageColors.warn(`[clear_sitedata before reload failed] ${currentUrl}: ${reloadClearErr.message}`));
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
|
-
await page.reload({ waitUntil: 'domcontentloaded', timeout: Math.min(timeout, 15000) });
|
|
2839
|
-
await fastTimeout(delayMs);
|
|
2815
|
+
// Handle reloads - use force reload mechanism if forcereload is enabled
|
|
2816
|
+
const totalReloads = (siteConfig.reload || 1) - 1; // Subtract 1 because initial load counts as first
|
|
2817
|
+
const useForceReload = siteConfig.forcereload === true;
|
|
2818
|
+
|
|
2819
|
+
if (useForceReload && forceDebug) {
|
|
2820
|
+
console.log(formatLogMessage('debug', `Using force reload mechanism for all ${totalReloads + 1} reload(s) on ${currentUrl}`));
|
|
2840
2821
|
}
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
if (
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2822
|
+
|
|
2823
|
+
for (let i = 1; i <= totalReloads; i++) {
|
|
2824
|
+
if (siteConfig.clear_sitedata === true) {
|
|
2825
|
+
try {
|
|
2826
|
+
let reloadClearSession = null;
|
|
2827
|
+
try {
|
|
2828
|
+
reloadClearSession = await page.target().createCDPSession();
|
|
2829
|
+
await reloadClearSession.send('Network.clearBrowserCookies');
|
|
2830
|
+
await reloadClearSession.send('Network.clearBrowserCache');
|
|
2831
|
+
} finally {
|
|
2832
|
+
if (reloadClearSession) {
|
|
2833
|
+
try { await reloadClearSession.detach(); } catch (detachErr) { /* ignore */ }
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
await page.evaluate(() => {
|
|
2837
|
+
localStorage.clear();
|
|
2838
|
+
sessionStorage.clear();
|
|
2839
|
+
indexedDB.databases().then(dbs => dbs.forEach(db => indexedDB.deleteDatabase(db.name)));
|
|
2840
|
+
});
|
|
2841
|
+
if (forceDebug) console.log(formatLogMessage('debug', `Cleared site data before reload #${i} for ${currentUrl}`));
|
|
2842
|
+
} catch (reloadClearErr) {
|
|
2843
|
+
console.warn(messageColors.warn(`[clear_sitedata before reload failed] ${currentUrl}: ${reloadClearErr.message}`));
|
|
2844
|
+
}
|
|
2851
2845
|
}
|
|
2846
|
+
|
|
2847
|
+
if (useForceReload) {
|
|
2848
|
+
// Force reload: disable cache, reload, re-enable cache
|
|
2849
|
+
try {
|
|
2850
|
+
await page.setCacheEnabled(false);
|
|
2851
|
+
await page.reload({ waitUntil: 'domcontentloaded', timeout: Math.min(timeout, 12000) });
|
|
2852
|
+
await page.setCacheEnabled(true);
|
|
2853
|
+
if (forceDebug) console.log(formatLogMessage('debug', `Force reload #${i} completed for ${currentUrl}`));
|
|
2854
|
+
} catch (forceReloadErr) {
|
|
2855
|
+
console.warn(messageColors.warn(`[force reload #${i} failed] ${currentUrl}: ${forceReloadErr.message}`));
|
|
2856
|
+
}
|
|
2857
|
+
} else {
|
|
2858
|
+
// Regular reload
|
|
2859
|
+
await page.reload({ waitUntil: 'domcontentloaded', timeout: Math.min(timeout, 15000) });
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2862
|
+
await fastTimeout(delayMs);
|
|
2852
2863
|
}
|
|
2853
2864
|
|
|
2854
2865
|
if (dryRunMode) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fanboynz/network-scanner",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.83",
|
|
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": {
|