@fanboynz/network-scanner 2.0.20 → 2.0.21
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.1 +32 -1
- package/nwss.js +77 -4
- package/package.json +1 -1
package/nwss.1
CHANGED
|
@@ -303,7 +303,7 @@ Number of times to reload the page (default: 1).
|
|
|
303
303
|
|
|
304
304
|
.TP
|
|
305
305
|
.B forcereload
|
|
306
|
-
Boolean. Force an
|
|
306
|
+
Boolean or Array. Force cache-clearing reload for all URLs or specific domains. Can be \fBtrue\fR/\fBfalse\fR or array of domain names like \fB["domain1.com", "domain2.com"]\fR. When set to \fBtrue\fR, applies to all URLs in the site configuration. When set to an array, applies only to URLs whose domains match the specified domains. Supports exact hostname matching and subdomain matching (e.g., "example.com" matches both "example.com" and "subdomain.example.com"). Domain matching is case-insensitive and automatically handles protocols, ports, and paths.
|
|
307
307
|
|
|
308
308
|
.TP
|
|
309
309
|
.B timeout
|
|
@@ -784,6 +784,37 @@ With default settings (\fBignore_similar_threshold: 80\fR):
|
|
|
784
784
|
}
|
|
785
785
|
.EE
|
|
786
786
|
|
|
787
|
+
.SS Force reload examples:
|
|
788
|
+
.EX
|
|
789
|
+
# Force reload for all URLs in a site configuration
|
|
790
|
+
{
|
|
791
|
+
"url": ["https://site1.com", "https://site2.com"],
|
|
792
|
+
"filterRegex": "ads|tracking",
|
|
793
|
+
"forcereload": true
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
# Force reload only for specific domains
|
|
797
|
+
{
|
|
798
|
+
"url": [
|
|
799
|
+
"https://example.com/page1",
|
|
800
|
+
"https://test.org/page2",
|
|
801
|
+
"https://demo.net/page3"
|
|
802
|
+
],
|
|
803
|
+
"filterRegex": "\\\\.(space|website)\\\\b",
|
|
804
|
+
"forcereload": ["example.com", "demo.net"],
|
|
805
|
+
"comments": [
|
|
806
|
+
"Only example.com and demo.net URLs get force reload",
|
|
807
|
+
"test.org URLs use standard reload"
|
|
808
|
+
]
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
# Mixed configuration with domain-specific force reload
|
|
812
|
+
{
|
|
813
|
+
"url": "https://cdn.example.com/content/page.html",
|
|
814
|
+
"forcereload": ["example.com"]
|
|
815
|
+
}
|
|
816
|
+
.EE
|
|
817
|
+
|
|
787
818
|
.SS Configuration with documentation comments:
|
|
788
819
|
.EX
|
|
789
820
|
{
|
package/nwss.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// === Network scanner script (nwss.js) v2.0.
|
|
1
|
+
// === Network scanner script (nwss.js) v2.0.21 ===
|
|
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.21'; // Script version
|
|
134
134
|
|
|
135
135
|
// get startTime
|
|
136
136
|
const startTime = Date.now();
|
|
@@ -516,7 +516,7 @@ Redirect Handling Options:
|
|
|
516
516
|
interact_intensity: "low"|"medium"|"high" Interaction simulation intensity (default: medium)
|
|
517
517
|
delay: <milliseconds> Delay after load (default: 4000)
|
|
518
518
|
reload: <number> Reload page n times after load (default: 1)
|
|
519
|
-
forcereload: true/false
|
|
519
|
+
forcereload: true/false or ["domain1.com", "domain2.com"] Force cache-clearing reload for all URLs or specific domains
|
|
520
520
|
clear_sitedata: true/false Clear all cookies, cache, storage before each load (default: false)
|
|
521
521
|
subDomains: 1/0 Output full subdomains (default: 0)
|
|
522
522
|
localhost: true/false Force localhost output (127.0.0.1)
|
|
@@ -3202,7 +3202,80 @@ function setupFrameHandling(page, forceDebug) {
|
|
|
3202
3202
|
updatePageUsage(page, true);
|
|
3203
3203
|
|
|
3204
3204
|
const totalReloads = (siteConfig.reload || 1) - 1; // Subtract 1 because initial load counts as first
|
|
3205
|
-
|
|
3205
|
+
|
|
3206
|
+
// Enhanced forcereload logic: support boolean or domain array
|
|
3207
|
+
let useForceReload = false;
|
|
3208
|
+
if (siteConfig.forcereload === true) {
|
|
3209
|
+
// Original behavior: force reload for all URLs
|
|
3210
|
+
useForceReload = true;
|
|
3211
|
+
} else if (Array.isArray(siteConfig.forcereload)) {
|
|
3212
|
+
// Input validation: filter out invalid entries
|
|
3213
|
+
const validDomains = siteConfig.forcereload.filter(domain => {
|
|
3214
|
+
if (typeof domain !== 'string') {
|
|
3215
|
+
if (forceDebug) {
|
|
3216
|
+
console.log(formatLogMessage('debug', `Invalid forcereload entry (not string): ${typeof domain} - ${JSON.stringify(domain)}`));
|
|
3217
|
+
}
|
|
3218
|
+
return false;
|
|
3219
|
+
}
|
|
3220
|
+
|
|
3221
|
+
if (domain.trim() === '') {
|
|
3222
|
+
if (forceDebug) {
|
|
3223
|
+
console.log(formatLogMessage('debug', `Invalid forcereload entry (empty string)`));
|
|
3224
|
+
}
|
|
3225
|
+
return false;
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
return true;
|
|
3229
|
+
});
|
|
3230
|
+
|
|
3231
|
+
if (validDomains.length === 0) {
|
|
3232
|
+
if (forceDebug) {
|
|
3233
|
+
console.log(formatLogMessage('debug', `No valid domains in forcereload array for ${currentUrl}`));
|
|
3234
|
+
}
|
|
3235
|
+
useForceReload = false;
|
|
3236
|
+
} else {
|
|
3237
|
+
// New behavior: force reload only for matching domains
|
|
3238
|
+
const currentDomain = safeGetDomain(currentUrl, true); // Get full hostname
|
|
3239
|
+
const currentRootDomain = safeGetDomain(currentUrl, false); // Get root domain
|
|
3240
|
+
|
|
3241
|
+
useForceReload = validDomains.some(domain => {
|
|
3242
|
+
// Enhanced domain cleaning: handle protocols, ports, paths, and normalize case
|
|
3243
|
+
let cleanDomain = domain.trim();
|
|
3244
|
+
cleanDomain = cleanDomain.replace(/^https?:\/\//, ''); // Remove protocol
|
|
3245
|
+
cleanDomain = cleanDomain.replace(/:\d+$/, ''); // Remove port (e.g., :8080)
|
|
3246
|
+
cleanDomain = cleanDomain.replace(/\/.*$/, ''); // Remove path
|
|
3247
|
+
cleanDomain = cleanDomain.toLowerCase(); // Normalize case
|
|
3248
|
+
|
|
3249
|
+
// Additional validation: basic domain format check
|
|
3250
|
+
if (!/^[a-z0-9.-]+$/.test(cleanDomain)) {
|
|
3251
|
+
if (forceDebug) {
|
|
3252
|
+
console.log(formatLogMessage('debug', `Skipping invalid domain format in forcereload: ${domain} -> ${cleanDomain}`));
|
|
3253
|
+
}
|
|
3254
|
+
return false;
|
|
3255
|
+
}
|
|
3256
|
+
|
|
3257
|
+
// Check if current URL matches this domain
|
|
3258
|
+
// Support both exact hostname match and subdomain match
|
|
3259
|
+
if (currentDomain.toLowerCase() === cleanDomain || currentRootDomain.toLowerCase() === cleanDomain) {
|
|
3260
|
+
return true;
|
|
3261
|
+
}
|
|
3262
|
+
|
|
3263
|
+
// Check if current hostname ends with the domain (subdomain match)
|
|
3264
|
+
if (currentDomain.toLowerCase().endsWith('.' + cleanDomain)) {
|
|
3265
|
+
return true;
|
|
3266
|
+
}
|
|
3267
|
+
|
|
3268
|
+
return false;
|
|
3269
|
+
});
|
|
3270
|
+
}
|
|
3271
|
+
|
|
3272
|
+
if (forceDebug && useForceReload) {
|
|
3273
|
+
console.log(formatLogMessage('debug', `Force reload enabled for ${currentUrl} - matches domain in forcereload list`));
|
|
3274
|
+
} else if (forceDebug && validDomains.length > 0) {
|
|
3275
|
+
console.log(formatLogMessage('debug', `Force reload not applied for ${currentUrl} - no domain match in [${validDomains.join(', ')}]`));
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
// If forcereload is not specified, false, or any other value, useForceReload remains false
|
|
3206
3279
|
|
|
3207
3280
|
if (useForceReload && forceDebug) {
|
|
3208
3281
|
console.log(formatLogMessage('debug', `Using force reload mechanism for all ${totalReloads + 1} reload(s) on ${currentUrl}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fanboynz/network-scanner",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.21",
|
|
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": {
|