nodebb-plugin-ezoic-infinite 1.4.21 → 1.4.23

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/client.js +33 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.4.21",
3
+ "version": "1.4.23",
4
4
  "description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/public/client.js CHANGED
@@ -414,6 +414,9 @@
414
414
  let scheduledAny = false;
415
415
 
416
416
  for (const wrap of wraps) {
417
+ // Skip les wrappers cachés par enforceNoAdjacentAds
418
+ if (wrap.style && wrap.style.display === 'none') continue;
419
+
417
420
  const ph = wrap.querySelector && wrap.querySelector(`[id^="${PLACEHOLDER_PREFIX}"]`);
418
421
  if (!ph) continue;
419
422
  const id = parseInt(ph.id.replace(PLACEHOLDER_PREFIX, ''), 10);
@@ -445,7 +448,12 @@
445
448
  const r = safeRect(wrap);
446
449
  if (r && (r.top > window.innerHeight + 1200 || r.bottom < -1200)) continue;
447
450
 
448
- state.retryById.set(id, tries + 1);
451
+ // Incrémenter le compteur seulement si Ezoic est chargé
452
+ // Sinon on est juste en attente de chargement, pas un vrai échec
453
+ const ezoicReady = window.ezstandalone && typeof window.ezstandalone.showAds === 'function';
454
+ if (ezoicReady) {
455
+ state.retryById.set(id, tries + 1);
456
+ }
449
457
  enqueueRetry(id);
450
458
  scheduledAny = true;
451
459
  }
@@ -515,7 +523,7 @@
515
523
  return;
516
524
  }
517
525
 
518
- if (attempts < 50) setTimeout(waitForPh, 50);
526
+ if (attempts < 100) setTimeout(waitForPh, 50);
519
527
  })();
520
528
  }
521
529
 
@@ -624,7 +632,10 @@
624
632
  continue;
625
633
  }
626
634
  if (!(pick.recycled && pick.recycled.wrap)) {
627
- callShowAdsWhenReady(id);
635
+ // Ne pas appeler showAds si cet ID a déjà été blacklisté
636
+ if (!state.badIds.has(id)) {
637
+ callShowAdsWhenReady(id);
638
+ }
628
639
  }
629
640
  inserted += 1;
630
641
  }
@@ -636,8 +647,22 @@
636
647
  for (let i = 0; i < ads.length; i++) {
637
648
  const ad = ads[i];
638
649
  const prev = ad.previousElementSibling;
639
- if (prev && prev.classList && prev.classList.contains(WRAP_CLASS)) ad.style.display = 'none';
640
- else ad.style.display = '';
650
+ if (prev && prev.classList && prev.classList.contains(WRAP_CLASS)) {
651
+ // Supprimer le wrapper adjacent au lieu de le cacher
652
+ try {
653
+ const ph = ad.querySelector && ad.querySelector(`[id^="${PLACEHOLDER_PREFIX}"]`);
654
+ if (ph) {
655
+ const id = parseInt(ph.id.replace(PLACEHOLDER_PREFIX, ''), 10);
656
+ if (Number.isFinite(id) && id > 0) {
657
+ // Détruire le placeholder si Ezoic l'a déjà défini
658
+ if (sessionDefinedIds.has(id)) {
659
+ destroyPlaceholderIds([id]);
660
+ }
661
+ }
662
+ }
663
+ ad.remove();
664
+ } catch (e) {}
665
+ }
641
666
  }
642
667
  }
643
668
 
@@ -831,6 +856,7 @@
831
856
  bindScroll();
832
857
  ensureObserver();
833
858
  state.pageKey = getPageKey();
834
- scheduleRun();
835
- setTimeout(scheduleRun, 300);
859
+ // Attendre un peu plus longtemps au démarrage initial pour Ezoic
860
+ setTimeout(scheduleRun, 800);
861
+ setTimeout(scheduleRun, 1500);
836
862
  })();