nodebb-plugin-ezoic-infinite 1.7.57 → 1.7.59

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 +5 -73
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.7.57",
3
+ "version": "1.7.59",
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
@@ -41,7 +41,6 @@
41
41
  const A_WRAPID = 'data-ezoic-wrapid'; // id Ezoic
42
42
 
43
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)
45
44
  const MAX_INSERTS_RUN = 6; // insertions max par appel runCore
46
45
  const MAX_INFLIGHT = 4; // showAds() simultanés max
47
46
  const SHOW_THROTTLE_MS = 900; // anti-spam showAds() par id
@@ -247,68 +246,6 @@
247
246
  return null;
248
247
  }
249
248
 
250
- /**
251
- * Pool épuisé : recycle un wrap loin au-dessus du viewport.
252
- * Séquence : destroy([id]) → 300ms → define([id]) → 300ms → displayMore([id])
253
- * Priorité : wraps vides d'abord, remplis si nécessaire.
254
- */
255
- function recycleAndMove(klass, targetEl, newKey) {
256
- const ez = window.ezstandalone;
257
- if (typeof ez?.destroyPlaceholders !== 'function' ||
258
- typeof ez?.define !== 'function' ||
259
- typeof ez?.displayMore !== 'function') return null;
260
-
261
- const threshold = -(window.innerHeight || 800);
262
- let bestEmpty = null, bestEmptyBottom = Infinity;
263
- let bestFilled = null, bestFilledBottom = Infinity;
264
-
265
- document.querySelectorAll(`.${WRAP_CLASS}.${klass}`).forEach(wrap => {
266
- try {
267
- const rect = wrap.getBoundingClientRect();
268
- if (rect.bottom > threshold) return;
269
- if (!isFilled(wrap)) {
270
- if (rect.bottom < bestEmptyBottom) { bestEmptyBottom = rect.bottom; bestEmpty = wrap; }
271
- } else {
272
- if (rect.bottom < bestFilledBottom) { bestFilledBottom = rect.bottom; bestFilled = wrap; }
273
- }
274
- } catch (_) {}
275
- });
276
-
277
- const best = bestEmpty ?? bestFilled;
278
- if (!best) return null;
279
- const id = parseInt(best.getAttribute(A_WRAPID), 10);
280
- if (!Number.isFinite(id)) return null;
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
- }
287
- S.recycling.add(id);
288
-
289
- const oldKey = best.getAttribute(A_ANCHOR);
290
- try { const ph = best.querySelector(`#${PH_PREFIX}${id}`); if (ph) S.io?.unobserve(ph); } catch (_) {}
291
- mutate(() => {
292
- best.setAttribute(A_ANCHOR, newKey);
293
- const ph = best.querySelector(`#${PH_PREFIX}${id}`);
294
- if (ph) ph.innerHTML = '';
295
- targetEl.insertAdjacentElement('afterend', best);
296
- });
297
- if (oldKey && S.wrapByKey.get(oldKey) === best) S.wrapByKey.delete(oldKey);
298
- S.wrapByKey.set(newKey, best);
299
-
300
- const doDestroy = () => { try { ez.destroyPlaceholders([id]); } catch (_) {} setTimeout(doDefine, 300); };
301
- const doDefine = () => { try { ez.define([id]); } catch (_) {} setTimeout(doDisplay, 300); };
302
- const doDisplay = () => {
303
- try { ez.displayMore([id]); } catch (_) {}
304
- S.recycling.delete(id);
305
- observePh(id);
306
- };
307
- try { typeof ez.cmd?.push === 'function' ? ez.cmd.push(doDestroy) : doDestroy(); } catch (_) {}
308
-
309
- return { id, wrap: best };
310
- }
311
-
312
249
  // ── Wraps DOM — création / suppression ────────────────────────────────────
313
250
 
314
251
  function makeWrap(id, klass, key) {
@@ -378,14 +315,9 @@
378
315
  const key = anchorKey(klass, el);
379
316
  if (findWrap(key)) continue;
380
317
  const id = pickId(poolKey);
381
- if (id) {
382
- const w = insertAfter(el, id, klass, key);
383
- if (w) { observePh(id); inserted++; }
384
- } else {
385
- const recycled = recycleAndMove(klass, el, key);
386
- if (!recycled) break;
387
- inserted++;
388
- }
318
+ if (!id) break;
319
+ const w = insertAfter(el, id, klass, key);
320
+ if (w) { observePh(id); inserted++; }
389
321
  }
390
322
  return inserted;
391
323
  }
@@ -466,7 +398,8 @@
466
398
  if (t - (S.lastShow.get(id) ?? 0) < SHOW_THROTTLE_MS) { clearTimeout(timer); return release(); }
467
399
  S.lastShow.set(id, t);
468
400
  // 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 (_) {}
401
+ // Si la pub charge après is-empty, retirer le collapse
402
+ try { document.getElementById(`${PH_PREFIX}${id}`)?.closest?.(`.${WRAP_CLASS}`)?.classList.remove('is-empty'); } catch (_) {}
470
403
  window.ezstandalone = window.ezstandalone || {};
471
404
  const ez = window.ezstandalone;
472
405
  const doShow = () => {
@@ -582,7 +515,6 @@
582
515
  S.mountedIds.clear();
583
516
  S.lastShow.clear();
584
517
  S.wrapByKey.clear();
585
- S.recycling.clear();
586
518
  S.inflight = 0;
587
519
  S.pending = [];
588
520
  S.pendingSet.clear();