nodebb-plugin-ezoic-infinite 1.4.38 → 1.4.39

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 +14 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.4.38",
3
+ "version": "1.4.39",
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
@@ -557,6 +557,7 @@
557
557
  // Les supprimer manuellement cause des problèmes avec l'état interne d'Ezoic
558
558
 
559
559
  if (state.obs) { state.obs.disconnect(); state.obs = null; }
560
+ state.canInsert = false;
560
561
  state.scheduled = false;
561
562
  clearTimeout(state.timer);
562
563
  state.timer = null;
@@ -569,6 +570,11 @@
569
570
  }
570
571
 
571
572
  async function runCore() {
573
+ // Attendre que canInsert soit true (protection race condition navigation)
574
+ if (!state.canInsert) {
575
+ return;
576
+ }
577
+
572
578
  patchShowAds();
573
579
 
574
580
  const cfg = await fetchConfig();
@@ -658,6 +664,14 @@
658
664
  $(window).on('action:ajaxify.end.ezoicInfinite', () => {
659
665
  state.pageKey = getPageKey();
660
666
  ensureObserver();
667
+
668
+ // CRITIQUE: Attendre 300ms avant de permettre l'insertion de nouveaux placeholders
669
+ // pour laisser les anciens showAds() (en cours) se terminer ou échouer proprement
670
+ // Sinon race condition: NodeBB vide le DOM pendant que Ezoic essaie d'accéder aux placeholders
671
+ state.canInsert = false;
672
+ setTimeout(() => {
673
+ state.canInsert = true;
674
+ }, 300);
661
675
  });
662
676
 
663
677
  $(window).on('action:category.loaded.ezoicInfinite', () => {