nodebb-plugin-ezoic-infinite 1.7.30 → 1.7.32

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 +58 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.7.30",
3
+ "version": "1.7.32",
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 v36
2
+ * NodeBB Ezoic Infinite Ads — client.js v37
3
3
  *
4
4
  * Historique des corrections majeures
5
5
  * ────────────────────────────────────
@@ -35,6 +35,10 @@
35
35
  * un div avec le même id déclenche "already been defined" et bloque
36
36
  * showAds(). En déplaçant le même nœud DOM, la registry reste valide.
37
37
  *
38
+ * v37 Fix wraps vides persistants : ez.refresh() sur les placeholders
39
+ * en DOM, connectés, non remplis et visibles (dans les marges IO).
40
+ * Appelé dans runCore() après injection, une fois par burst max.
41
+ *
38
42
  * v36 Optimisations chemin critique (scroll → injectBetween) :
39
43
  * – S.wrapByKey Map<anchorKey,wrap> : findWrap() passe de querySelector
40
44
  * sur tout le doc à un lookup O(1). Mis à jour dans insertAfter,
@@ -615,23 +619,70 @@
615
619
  return injectBetween(klass, getItems(), interval, normBool(cfgShowFirst), poolKey);
616
620
  };
617
621
 
618
- if (kind === 'topic') return exec(
619
- 'ezoic-ad-message', getPosts,
620
- cfg.enableMessageAds, cfg.messageIntervalPosts, cfg.showFirstMessageAd, 'posts'
621
- );
622
+ if (kind === 'topic') {
623
+ const n = exec(
624
+ 'ezoic-ad-message', getPosts,
625
+ cfg.enableMessageAds, cfg.messageIntervalPosts, cfg.showFirstMessageAd, 'posts'
626
+ );
627
+ refreshStaleWraps();
628
+ return n;
629
+ }
622
630
 
623
631
  if (kind === 'categoryTopics') {
624
632
  pruneOrphansBetween();
625
- return exec(
633
+ const n = exec(
626
634
  'ezoic-ad-between', getTopics,
627
635
  cfg.enableBetweenAds, cfg.intervalPosts, cfg.showFirstTopicAd, 'topics'
628
636
  );
637
+ refreshStaleWraps();
638
+ return n;
629
639
  }
630
640
 
631
- return exec(
641
+ const n2 = exec(
632
642
  'ezoic-ad-categories', getCategories,
633
643
  cfg.enableCategoryAds, cfg.intervalCategories, cfg.showFirstCategoryAd, 'categories'
634
644
  );
645
+ refreshStaleWraps();
646
+ return n2;
647
+ }
648
+
649
+ /**
650
+ * Appelle ez.refresh() sur les placeholders en DOM, non remplis,
651
+ * dans la zone visible (marges IO). Cela force Ezoic à re-servir
652
+ * une pub sur des slots qu'il avait refusé lors du showAds() initial.
653
+ * Limité à MAX_REFRESH_PER_RUN appels par invocation.
654
+ */
655
+ const MAX_REFRESH_PER_RUN = 3;
656
+
657
+ function refreshStaleWraps() {
658
+ const ez = window.ezstandalone;
659
+ if (typeof ez?.refresh !== 'function') return;
660
+
661
+ const vh = window.innerHeight || 800;
662
+ const margin = (isMobile() ? 3500 : 2500);
663
+ const top = -margin;
664
+ const bot = vh + margin;
665
+
666
+ const ids = [];
667
+ for (const [, wrap] of S.wrapByKey) {
668
+ if (ids.length >= MAX_REFRESH_PER_RUN) break;
669
+ if (!wrap.isConnected || isFilled(wrap)) continue;
670
+ // Vérifier que le wrap a déjà eu un showAds (A_SHOWN > 0)
671
+ const shown = parseInt(wrap.getAttribute(A_SHOWN) || '0', 10);
672
+ if (!shown) continue;
673
+ try {
674
+ const rect = wrap.getBoundingClientRect();
675
+ if (rect.top > bot || rect.bottom < top) continue;
676
+ const id = parseInt(wrap.getAttribute(A_WRAPID), 10);
677
+ if (Number.isFinite(id) && id > 0) ids.push(id);
678
+ } catch (_) {}
679
+ }
680
+
681
+ if (!ids.length) return;
682
+ try {
683
+ const doRefresh = () => { try { ez.refresh(ids); } catch (_) {} };
684
+ Array.isArray(ez.cmd) ? ez.cmd.push(doRefresh) : doRefresh();
685
+ } catch (_) {}
635
686
  }
636
687
 
637
688
  // ── Scheduler ──────────────────────────────────────────────────────────────