nodebb-plugin-ezoic-infinite 1.7.27 → 1.7.29

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 +30 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.7.27",
3
+ "version": "1.7.29",
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
@@ -1,5 +1,5 @@
1
1
  /**
2
- * NodeBB Ezoic Infinite Ads — client.js v33
2
+ * NodeBB Ezoic Infinite Ads — client.js v34
3
3
  *
4
4
  * Historique des corrections majeures
5
5
  * ────────────────────────────────────
@@ -262,11 +262,13 @@
262
262
  return null;
263
263
  }
264
264
 
265
- function recycleDistantWrap(klass) {
266
- // Quand le pool est épuisé : récupère le wrap le plus loin au-dessus du
267
- // viewport (qu'il soit orphelin ou non) pour libérer son ID.
268
- // Les topics/pubs à 4+ viewports au-dessus ne sont plus visibles — on peut
269
- // recycler leur slot. Non-remplis en priorité, remplis si rien d'autre.
265
+ function moveDistantWrap(klass, targetEl, newKey) {
266
+ // Quand le pool est épuisé : déplace un wrap loin au-dessus du viewport
267
+ // vers la nouvelle position cible. On NE supprime PAS le div placeholder —
268
+ // Ezoic garde sa registry interne et "already been defined" bloque showAds()
269
+ // si on recrée le même ID. En déplaçant le wrap, le placeholder DOM reste
270
+ // le même nœud → Ezoic ne se plaint pas.
271
+ // Priorité : wraps vides d'abord (non remplis = pas de pub perdue).
270
272
  const vh = window.innerHeight || 800;
271
273
  const threshold = -vh * 4;
272
274
 
@@ -287,10 +289,20 @@
287
289
 
288
290
  const best = bestEmpty ?? bestFilled;
289
291
  if (!best) return null;
292
+
290
293
  const id = parseInt(best.getAttribute(A_WRAPID), 10);
291
294
  if (!Number.isFinite(id)) return null;
292
- mutate(() => dropWrap(best));
293
- return id;
295
+
296
+ // Déplacer le wrap après targetEl (même nœud DOM, pas de recréation)
297
+ mutate(() => {
298
+ best.setAttribute(A_ANCHOR, newKey);
299
+ best.setAttribute(A_CREATED, String(ts()));
300
+ best.setAttribute(A_SHOWN, '');
301
+ best.classList.remove('is-empty');
302
+ targetEl.insertAdjacentElement('afterend', best);
303
+ });
304
+
305
+ return { id, wrap: best };
294
306
  }
295
307
 
296
308
  // ── Wraps DOM ──────────────────────────────────────────────────────────────
@@ -409,10 +421,16 @@
409
421
  if (findWrap(key)) continue;
410
422
 
411
423
  let id = pickId(poolKey);
412
- if (!id) { id = recycleDistantWrap(klass); if (!id) continue; }
413
-
414
- const w = insertAfter(el, id, klass, key);
415
- if (w) { observePh(id); inserted++; }
424
+ if (id) {
425
+ const w = insertAfter(el, id, klass, key);
426
+ if (w) { observePh(id); inserted++; }
427
+ } else {
428
+ // Pool épuisé : déplacer un wrap distant (ne recrée PAS le placeholder)
429
+ const moved = moveDistantWrap(klass, el, key);
430
+ if (!moved) continue;
431
+ observePh(moved.id);
432
+ inserted++;
433
+ }
416
434
  }
417
435
  return inserted;
418
436
  }