nodebb-plugin-ezoic-infinite 1.7.55 → 1.7.57

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 +18 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.7.55",
3
+ "version": "1.7.57",
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 v60
2
+ * NodeBB Ezoic Infinite Ads — client.js v62
3
3
  *
4
4
  * Historique
5
5
  * ──────────
@@ -18,7 +18,10 @@
18
18
  * v53 S.recycling garde double-recyclage. pickId early-exit. cleanup complet.
19
19
  * v54 ensureTcfLocator rappelé à chaque ajaxify.end.
20
20
  * v56 scheduleEmptyCheck / is-empty supprimés (collapse prématuré).
21
- * v60 is-empty réintroduit avec délai 60s et collapse à 0px (ligne visible).
21
+ * v62 is-empty réintroduit : collapse 60s après insertion du wrap (pas après
22
+ * showAds) si isFilled est toujours false. Évite les trous permanents.
23
+ * v61 recycleAndMove : ne pas recycler un wrap rempli depuis moins de 30s.
24
+ * Empêche qu'une pub qui vient de charger soit déplacée immédiatement.
22
25
  * v59 CSS : min-height 90px sur ezoic-ad-between (anti-CLS AMP ads).
23
26
  * v58 tcfObs survit aux navigations : ne plus déconnecter dans cleanup().
24
27
  * L'iframe __tcfapiLocator doit exister en permanence pour le CMP —
@@ -37,7 +40,8 @@
37
40
  const A_ANCHOR = 'data-ezoic-anchor'; // "kindClass:stableId"
38
41
  const A_WRAPID = 'data-ezoic-wrapid'; // id Ezoic
39
42
 
40
- const EMPTY_CHECK_MS = 60_000; // délai avant collapse wrap vide (60s — laisser le temps au CMP/enchères)
43
+ const EMPTY_CHECK_MS = 60_000;
44
+ const RECYCLE_MIN_AGE_MS = 30_000; // délai minimal avant recyclage d'un wrap rempli // délai avant collapse wrap vide (60s — laisser le temps au CMP/enchères)
41
45
  const MAX_INSERTS_RUN = 6; // insertions max par appel runCore
42
46
  const MAX_INFLIGHT = 4; // showAds() simultanés max
43
47
  const SHOW_THROTTLE_MS = 900; // anti-spam showAds() par id
@@ -275,6 +279,11 @@
275
279
  const id = parseInt(best.getAttribute(A_WRAPID), 10);
276
280
  if (!Number.isFinite(id)) return null;
277
281
  if (S.recycling.has(id)) return null;
282
+ // Ne pas recycler un wrap rempli depuis moins de RECYCLE_MIN_AGE_MS
283
+ if (best === bestFilled) {
284
+ const filledAt = parseInt(best.getAttribute('data-ezoic-filled') || '0', 10);
285
+ if (ts() - filledAt < RECYCLE_MIN_AGE_MS) return null;
286
+ }
278
287
  S.recycling.add(id);
279
288
 
280
289
  const oldKey = best.getAttribute(A_ANCHOR);
@@ -324,6 +333,7 @@
324
333
  mutate(() => el.insertAdjacentElement('afterend', w));
325
334
  S.mountedIds.add(id);
326
335
  S.wrapByKey.set(key, w);
336
+ scheduleEmptyCheck(id);
327
337
  return w;
328
338
  }
329
339
 
@@ -415,15 +425,14 @@
415
425
  startShow(id);
416
426
  }
417
427
 
418
- function scheduleEmptyCheck(id, showTs) {
428
+ function scheduleEmptyCheck(id) {
419
429
  setTimeout(() => {
420
430
  try {
421
431
  const ph = document.getElementById(`${PH_PREFIX}${id}`);
422
432
  const wrap = ph?.closest?.(`.${WRAP_CLASS}`);
423
433
  if (!wrap || !ph?.isConnected) return;
424
- // Ne pas écraser un showAds plus récent
425
- if ((S.lastShow.get(id) ?? 0) > showTs) return;
426
- wrap.classList.toggle('is-empty', !isFilled(ph));
434
+ // Collapse uniquement si vraiment vide après 60s
435
+ if (!isFilled(wrap)) wrap.classList.add('is-empty');
427
436
  } catch (_) {}
428
437
  }, EMPTY_CHECK_MS);
429
438
  }
@@ -456,11 +465,12 @@
456
465
  const t = ts();
457
466
  if (t - (S.lastShow.get(id) ?? 0) < SHOW_THROTTLE_MS) { clearTimeout(timer); return release(); }
458
467
  S.lastShow.set(id, t);
468
+ // Marquer le wrap avec le timestamp de fill pour bloquer le recyclage
469
+ try { const w = document.getElementById(`${PH_PREFIX}${id}`)?.closest?.(`.${WRAP_CLASS}`); if (w) { w.setAttribute('data-ezoic-filled', String(t)); w.classList.remove('is-empty'); } } catch (_) {}
459
470
  window.ezstandalone = window.ezstandalone || {};
460
471
  const ez = window.ezstandalone;
461
472
  const doShow = () => {
462
473
  try { ez.showAds(id); } catch (_) {}
463
- scheduleEmptyCheck(id, t);
464
474
  setTimeout(() => { clearTimeout(timer); release(); }, 700);
465
475
  };
466
476
  Array.isArray(ez.cmd) ? ez.cmd.push(doShow) : doShow();