@fanboynz/network-scanner 2.0.45 → 2.0.46

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 CHANGED
@@ -425,7 +425,5 @@ async function createEnhancedCDPSession(page, currentUrl, options = {}) {
425
425
  module.exports = {
426
426
  createCDPSession,
427
427
  createPageWithTimeout,
428
- setRequestInterceptionWithTimeout,
429
- validateCDPConfig,
430
- createEnhancedCDPSession
428
+ setRequestInterceptionWithTimeout
431
429
  };
@@ -345,6 +345,5 @@ async function clearSiteDataEnhanced(page, currentUrl, forceDebug) {
345
345
  module.exports = {
346
346
  clearSiteData,
347
347
  clearSiteDataViaCDP,
348
- clearSiteDataViaPage,
349
- clearSiteDataEnhanced
348
+ clearSiteDataViaPage
350
349
  };
@@ -373,7 +373,6 @@ async function humanLikeMouseMove(page, fromX, fromY, toX, toY, options = {}) {
373
373
 
374
374
  // Add slight curve to movement (more human-like)
375
375
  if (curve > 0 && i > 0 && i < actualSteps) {
376
- const midpoint = actualSteps / 2;
377
376
  const curveIntensity = Math.sin((i / actualSteps) * Math.PI) * curve * distance * MOUSE_MOVEMENT.CURVE_INTENSITY_RATIO;
378
377
  const perpX = -(toY - fromY) / distance;
379
378
  const perpY = (toX - fromX) / distance;
@@ -449,7 +448,7 @@ async function simulateScrolling(page, options = {}) {
449
448
  // Smooth scrolling by breaking into smaller increments
450
449
  for (let j = 0; j < smoothness; j++) {
451
450
  await page.mouse.wheel({ deltaY: scrollDelta / smoothness });
452
- await new Promise(resolve => setTimeout(resolve, SCROLLING.SMOOTH_INCREMENT_DELAY));
451
+ await fastTimeout(SCROLLING.SMOOTH_INCREMENT_DELAY);
453
452
  }
454
453
 
455
454
  if (i < amount - 1) {
@@ -549,7 +548,7 @@ async function interactWithElements(page, options = {}) {
549
548
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
550
549
  try {
551
550
  // Find visible, clickable elements
552
- const elements = await page.evaluate((selectors, avoidWords) => {
551
+ const elements = await page.evaluate((selectors, avoidWords, textPreviewLen) => {
553
552
  const clickableElements = [];
554
553
 
555
554
  selectors.forEach(selector => {
@@ -571,7 +570,7 @@ async function interactWithElements(page, options = {}) {
571
570
  y: rect.top + rect.height / 2,
572
571
  width: rect.width,
573
572
  height: rect.height,
574
- text: text.substring(0, ELEMENT_INTERACTION.TEXT_PREVIEW_LENGTH)
573
+ text: text.substring(0, textPreviewLen)
575
574
  });
576
575
  }
577
576
  }
@@ -579,7 +578,7 @@ async function interactWithElements(page, options = {}) {
579
578
  });
580
579
 
581
580
  return clickableElements;
582
- }, elementTypes, avoidDestructive ? ['delete', 'remove', 'submit', 'buy', 'purchase', 'order'] : []);
581
+ }, elementTypes, avoidDestructive ? ['delete', 'remove', 'submit', 'buy', 'purchase', 'order'] : [], ELEMENT_INTERACTION.TEXT_PREVIEW_LENGTH);
583
582
 
584
583
  if (elements.length > 0) {
585
584
  // Choose a random element to interact with
@@ -590,12 +589,12 @@ async function interactWithElements(page, options = {}) {
590
589
  await humanLikeMouseMove(page, currentPos.x, currentPos.y, element.x, element.y);
591
590
 
592
591
  // Brief pause before clicking
593
- await fastTimeout(TIMING.CLICK_PAUSE_MIN + Math.random() * TIMING.CLICK_PAUSE_MAX);
592
+ await fastTimeout(TIMING.CLICK_PAUSE_MIN + Math.random() * (TIMING.CLICK_PAUSE_MAX - TIMING.CLICK_PAUSE_MIN));
594
593
 
595
594
  await page.mouse.click(element.x, element.y);
596
595
 
597
596
  // Brief pause after clicking
598
- await fastTimeout(TIMING.POST_CLICK_MIN + Math.random() * TIMING.POST_CLICK_MAX);
597
+ await fastTimeout(TIMING.POST_CLICK_MIN + Math.random() * (TIMING.POST_CLICK_MAX - TIMING.POST_CLICK_MIN));
599
598
  }
600
599
  } catch (elementErr) {
601
600
  // Continue to next attempt if this one fails
@@ -673,9 +672,9 @@ async function simulateTyping(page, text, options = {}) {
673
672
  if (mistakes && Math.random() < mistakeRate) {
674
673
  const wrongChar = String.fromCharCode(97 + Math.floor(Math.random() * 26));
675
674
  await page.keyboard.type(wrongChar);
676
- await fastTimeout(TIMING.MISTAKE_PAUSE_MIN + Math.random() * TIMING.MISTAKE_PAUSE_MAX);
675
+ await fastTimeout(TIMING.MISTAKE_PAUSE_MIN + Math.random() * (TIMING.MISTAKE_PAUSE_MAX - TIMING.MISTAKE_PAUSE_MIN));
677
676
  await page.keyboard.press('Backspace');
678
- await fastTimeout(TIMING.BACKSPACE_DELAY_MIN + Math.random() * TIMING.BACKSPACE_DELAY_MAX);
677
+ await fastTimeout(TIMING.BACKSPACE_DELAY_MIN + Math.random() * (TIMING.BACKSPACE_DELAY_MAX - TIMING.BACKSPACE_DELAY_MIN));
679
678
  }
680
679
 
681
680
  await page.keyboard.type(char);
@@ -818,6 +817,7 @@ async function performPageInteraction(page, currentUrl, options = {}, forceDebug
818
817
  }
819
818
  return;
820
819
  }
820
+ await bodyExists.dispose();
821
821
  } catch (bodyCheckErr) {
822
822
  if (forceDebug) {
823
823
  console.log(`[interaction] Page not ready for interaction on ${currentUrl} (waited ${Math.min(Math.max((options.siteTimeout || 20000) / 8, 2000), 5000)}ms): ${bodyCheckErr.message}`);
@@ -922,6 +922,7 @@ async function performPageInteraction(page, currentUrl, options = {}, forceDebug
922
922
  const bodyElement = await page.$('body');
923
923
  if (bodyElement) {
924
924
  await page.hover('body');
925
+ await bodyElement.dispose();
925
926
  }
926
927
  } catch (hoverErr) {
927
928
  // Silently handle hover failures - not critical
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fanboynz/network-scanner",
3
- "version": "2.0.45",
3
+ "version": "2.0.46",
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": {