nodebb-plugin-ezoic-infinite 1.4.20 → 1.4.22

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 +32 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.4.20",
3
+ "version": "1.4.22",
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);
@@ -491,8 +494,13 @@
491
494
  attempts += 1;
492
495
  const el = document.getElementById(phId);
493
496
  if (el && el.isConnected) {
494
- if (doCall()) return;
497
+ // Si doCall() réussit, Ezoic est chargé et showAds a été appelé → sortir
498
+ if (doCall()) {
499
+ state.pendingById.delete(id); // nettoyage au cas où
500
+ return;
501
+ }
495
502
 
503
+ // Ezoic n'est pas encore chargé → attendre via cmd queue
496
504
  state.pendingById.add(id);
497
505
 
498
506
  window.ezstandalone = window.ezstandalone || {};
@@ -506,17 +514,7 @@
506
514
  }
507
515
  } catch (e) {}
508
516
  });
509
-
510
- let tries = 0;
511
- (function tick() {
512
- if (state.pageKey !== startPageKey) { state.pendingById.delete(id); return; }
513
- tries += 1;
514
- if (doCall() || tries >= 5) {
515
- if (tries >= 5) state.pendingById.delete(id);
516
- return;
517
- }
518
- setTimeout(tick, 700);
519
- })();
517
+ // cmd.push suffit - pas besoin de tick() qui crée des doublons
520
518
  return;
521
519
  }
522
520
 
@@ -629,7 +627,10 @@
629
627
  continue;
630
628
  }
631
629
  if (!(pick.recycled && pick.recycled.wrap)) {
632
- callShowAdsWhenReady(id);
630
+ // Ne pas appeler showAds si cet ID a déjà été blacklisté
631
+ if (!state.badIds.has(id)) {
632
+ callShowAdsWhenReady(id);
633
+ }
633
634
  }
634
635
  inserted += 1;
635
636
  }
@@ -641,8 +642,22 @@
641
642
  for (let i = 0; i < ads.length; i++) {
642
643
  const ad = ads[i];
643
644
  const prev = ad.previousElementSibling;
644
- if (prev && prev.classList && prev.classList.contains(WRAP_CLASS)) ad.style.display = 'none';
645
- else ad.style.display = '';
645
+ if (prev && prev.classList && prev.classList.contains(WRAP_CLASS)) {
646
+ // Supprimer le wrapper adjacent au lieu de le cacher
647
+ try {
648
+ const ph = ad.querySelector && ad.querySelector(`[id^="${PLACEHOLDER_PREFIX}"]`);
649
+ if (ph) {
650
+ const id = parseInt(ph.id.replace(PLACEHOLDER_PREFIX, ''), 10);
651
+ if (Number.isFinite(id) && id > 0) {
652
+ // Détruire le placeholder si Ezoic l'a déjà défini
653
+ if (sessionDefinedIds.has(id)) {
654
+ destroyPlaceholderIds([id]);
655
+ }
656
+ }
657
+ }
658
+ ad.remove();
659
+ } catch (e) {}
660
+ }
646
661
  }
647
662
  }
648
663
 
@@ -784,9 +799,9 @@
784
799
  $(window).on('action:ajaxify.end.ezoicInfinite', () => {
785
800
  state.pageKey = getPageKey();
786
801
  ensureObserver();
787
- // Attendre que le DOM soit stable avant d'insérer
788
- setTimeout(scheduleRun, 150);
802
+ // Attendre que le DOM soit stable ET que Ezoic se charge
789
803
  setTimeout(scheduleRun, 500);
804
+ setTimeout(scheduleRun, 1200);
790
805
  });
791
806
 
792
807
  $(window).on('action:category.loaded.ezoicInfinite', () => {