nodebb-plugin-ezoic-infinite 1.4.25 → 1.4.26

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 +23 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.4.25",
3
+ "version": "1.4.26",
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
@@ -10,12 +10,12 @@
10
10
  }, WRAP_CLASS = 'ezoic-ad';
11
11
  const PLACEHOLDER_PREFIX = 'ezoic-pub-ad-placeholder-', MAX_INSERTS_PER_RUN = 3;
12
12
 
13
- // IDs ayant été définis par Ezoic au moins une fois dans cette session navigateur.
14
- // Survit aux navigations ajaxify (contrairement à state.definedIds remis à zéro dans cleanup).
13
+
14
+
15
15
  // Nécessaire pour savoir si on doit appeler destroyPlaceholders avant recyclage.
16
16
  const sessionDefinedIds = new Set();
17
17
 
18
- // IDs actuellement en cours d'insertion (lock pour éviter les doublons de race condition)
18
+
19
19
  const insertingIds = new Set(), state = {
20
20
  pageKey: null,
21
21
  cfg: null,
@@ -164,7 +164,7 @@
164
164
  try {
165
165
  if (!wrap) return;
166
166
  try { wrap.removeAttribute('data-ezoic-filled'); } catch (e) {}
167
- try { if (wrap.__ezoicFillObs) { wrap.__ezoicFillObs.disconnect(); wrap.__ezoicFillObs = null; } } catch (e) {}
167
+ if (wrap.__ezoicFillObs) { wrap.__ezoicFillObs.disconnect(); wrap.__ezoicFillObs = null; }
168
168
  const old = wrap.querySelector && wrap.querySelector(`#${PLACEHOLDER_PREFIX}${id}`);
169
169
  if (old) old.remove();
170
170
  // Remove any leftover markup inside wrapper
@@ -279,7 +279,7 @@
279
279
  try {
280
280
  if (!wrap) return;
281
281
  // Disconnect the fill observer first (no need to remove+re-add the attribute)
282
- try { if (wrap.__ezoicFillObs) { wrap.__ezoicFillObs.disconnect(); wrap.__ezoicFillObs = null; } } catch (e) {}
282
+ if (wrap.__ezoicFillObs) { wrap.__ezoicFillObs.disconnect(); wrap.__ezoicFillObs = null; }
283
283
  wrap.setAttribute('data-ezoic-filled', '1');
284
284
  } catch (e) {}
285
285
  }
@@ -538,13 +538,15 @@
538
538
  state.liveMessage = [];
539
539
  state.liveCategory = [];
540
540
 
541
- state.lastShowById = new Map();
542
- state.pendingById = new Set();
543
- state.definedIds = new Set();
541
+ state.lastShowById.clear();
542
+ state.pendingById.clear();
543
+ state.definedIds.clear();
544
544
 
545
- document.querySelectorAll(`.${WRAP_CLASS}`).forEach(el => el.remove());
545
+ // NE PAS supprimer les wrappers Ezoic ici - ils seront supprimés naturellement
546
+ // quand NodeBB vide le DOM lors de la navigation ajaxify
547
+ // Les supprimer manuellement cause des problèmes avec l'état interne d'Ezoic
546
548
 
547
- if (state.obs) { try { state.obs.disconnect(); } catch (e) {} state.obs = null; }
549
+ if (state.obs) { state.obs.disconnect(); state.obs = null; }
548
550
  state.scheduled = false;
549
551
  clearTimeout(state.timer);
550
552
  state.timer = null;
@@ -645,19 +647,17 @@
645
647
  $(window).on('action:ajaxify.end.ezoicInfinite', () => {
646
648
  state.pageKey = getPageKey();
647
649
  ensureObserver();
648
- // CRITIQUE : Après navigation ajaxify, Ezoic est déjà chargé mais ne sait pas
649
- // qu'on va insérer de nouveaux placeholders. Il faut le forcer à re-scanner.
650
- try {
651
- if (window.ezstandalone && typeof window.ezstandalone.enable === 'function') {
652
- // enable() force Ezoic à re-scanner toute la page
653
- window.ezstandalone.enable();
654
- }
655
- } catch (e) {
656
-
657
- }
658
- // Attendre que les nouveaux placeholders soient dans le DOM
659
- setTimeout(scheduleRun, 500);
660
- setTimeout(scheduleRun, 1000);
650
+
651
+ // Attendre que NodeBB ait fini de construire le DOM
652
+ // (ajaxify.end se déclenche avant que le contenu soit vraiment prêt)
653
+ setTimeout(() => {
654
+ scheduleRun();
655
+ }, 800);
656
+
657
+ // Second pass pour être sûr
658
+ setTimeout(() => {
659
+ scheduleRun();
660
+ }, 1500);
661
661
  });
662
662
 
663
663
  $(window).on('action:category.loaded.ezoicInfinite', () => {