nodebb-plugin-ezoic-infinite 1.4.24 → 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 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.4.24",
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
  }
@@ -326,10 +326,6 @@
326
326
  return filled;
327
327
  }
328
328
 
329
- function scheduleRefill(delay = 350) {
330
- state.retryTimer = setTimeout(refillUnfilled, delay);
331
- }
332
-
333
329
  function callShowAdsWhenReady(id) {
334
330
  if (!id) return;
335
331
 
@@ -542,13 +538,15 @@
542
538
  state.liveMessage = [];
543
539
  state.liveCategory = [];
544
540
 
545
- state.lastShowById = new Map();
546
- state.pendingById = new Set();
547
- state.definedIds = new Set();
541
+ state.lastShowById.clear();
542
+ state.pendingById.clear();
543
+ state.definedIds.clear();
548
544
 
549
- 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
550
548
 
551
- if (state.obs) { try { state.obs.disconnect(); } catch (e) {} state.obs = null; }
549
+ if (state.obs) { state.obs.disconnect(); state.obs = null; }
552
550
  state.scheduled = false;
553
551
  clearTimeout(state.timer);
554
552
  state.timer = null;
@@ -649,19 +647,17 @@
649
647
  $(window).on('action:ajaxify.end.ezoicInfinite', () => {
650
648
  state.pageKey = getPageKey();
651
649
  ensureObserver();
652
- // CRITIQUE : Après navigation ajaxify, Ezoic est déjà chargé mais ne sait pas
653
- // qu'on va insérer de nouveaux placeholders. Il faut le forcer à re-scanner.
654
- try {
655
- if (window.ezstandalone && typeof window.ezstandalone.enable === 'function') {
656
- // enable() force Ezoic à re-scanner toute la page
657
- window.ezstandalone.enable();
658
- }
659
- } catch (e) {
660
-
661
- }
662
- // Attendre que les nouveaux placeholders soient dans le DOM
663
- setTimeout(scheduleRun, 500);
664
- 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);
665
661
  });
666
662
 
667
663
  $(window).on('action:category.loaded.ezoicInfinite', () => {