nodebb-plugin-ezoic-infinite 1.5.64 → 1.5.66

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.5.64",
3
+ "version": "1.5.66",
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
@@ -82,6 +82,10 @@
82
82
  io: null,
83
83
  runQueued: false,
84
84
 
85
+ needsMoreRun: false,
86
+ moreRunBurst: 0,
87
+ moreRunLast: 0,
88
+
85
89
  // preloading budget
86
90
  inflight: 0,
87
91
  pending: [],
@@ -99,6 +103,16 @@
99
103
 
100
104
  const insertingIds = new Set();
101
105
 
106
+ function unemptyIfFilled(wrap, ph) {
107
+ try {
108
+ if (!wrap || !ph) return false;
109
+ const hasAd = !!(ph.querySelector && ph.querySelector('iframe, ins, img, .ez-ad, .ezoic-ad'));
110
+ if (hasAd) wrap.classList.remove('is-empty');
111
+ return hasAd;
112
+ } catch (e) { return false; }
113
+ }
114
+
115
+
102
116
 
103
117
  function markEmptyWrapper(id) {
104
118
  try {
@@ -116,6 +130,17 @@
116
130
  // consider empty if only whitespace and no iframes/ins/img
117
131
  const hasAd = !!(ph2.querySelector && ph2.querySelector('iframe, ins, img, .ez-ad, .ezoic-ad'));
118
132
  if (!hasAd) w2.classList.add('is-empty');
133
+ // If the ad fills later, immediately uncollapse to avoid "missing ads" perception.
134
+ if (!unemptyIfFilled(w2, ph2)) {
135
+ try {
136
+ const mo = new MutationObserver(() => {
137
+ if (unemptyIfFilled(w2, ph2)) { try { mo.disconnect(); } catch (e) {} }
138
+ });
139
+ mo.observe(ph2, { childList: true, subtree: true });
140
+ // safety stop
141
+ setTimeout(() => { try { mo.disconnect(); } catch (e) {} }, 30000);
142
+ } catch (e) {}
143
+ }
119
144
  } catch (e) {}
120
145
  }, 3500);
121
146
  } catch (e) {}
@@ -695,8 +720,10 @@ function startShow(id) {
695
720
  let inserted = 0;
696
721
  const maxInserts = MAX_INSERTS_PER_RUN + (isBoosted() ? 1 : 0);
697
722
 
723
+ let hitLimit = false;
724
+
698
725
  for (const afterPos of targets) {
699
- if (inserted >= maxInserts) break;
726
+ if (inserted >= maxInserts) { hitLimit = true; break; }
700
727
 
701
728
  const el = items[afterPos - 1];
702
729
  if (!el || !el.isConnected) continue;
@@ -728,6 +755,11 @@ function startShow(id) {
728
755
  inserted += 1;
729
756
  }
730
757
 
758
+ if (hitLimit) {
759
+ // We intentionally cap per run for smoothness. If we hit the cap, queue another pass.
760
+ state.needsMoreRun = true;
761
+ }
762
+
731
763
  return inserted;
732
764
  }
733
765
 
@@ -739,6 +771,8 @@ function startShow(id) {
739
771
 
740
772
  initPools(cfg);
741
773
 
774
+ state.needsMoreRun = false;
775
+
742
776
  const kind = getKind();
743
777
  let items = [];
744
778
  let allIds = [];
@@ -845,6 +879,18 @@ function startShow(id) {
845
879
  declusterWraps('ezoic-ad-categories');
846
880
  }
847
881
  }
882
+ // If we hit the per-run insertion cap, schedule another pass soon.
883
+ // Guard against infinite loops when nothing more can be inserted (e.g. no ids / adjacency everywhere).
884
+ if (state.needsMoreRun) {
885
+ const now = Date.now();
886
+ if (now - state.moreRunLast > 800) state.moreRunBurst = 0;
887
+ state.moreRunLast = now;
888
+ state.moreRunBurst += 1;
889
+ if (state.moreRunBurst <= 8) {
890
+ setTimeout(scheduleRun, 60);
891
+ }
892
+ }
893
+
848
894
  }
849
895
 
850
896
  function scheduleRun() {
package/public/style.css CHANGED
@@ -29,17 +29,17 @@
29
29
  display: block !important;
30
30
  margin: 0 !important;
31
31
  padding: 0 !important;
32
- height: 0 !important;
33
- min-height: 0 !important;
32
+ height: 1px !important;
33
+ min-height: 1px !important;
34
34
  overflow: hidden !important;
35
35
  }
36
36
 
37
37
  .nodebb-ezoic-wrap {
38
- min-height: 0 !important;
38
+ min-height: 1px !important;
39
39
  }
40
40
 
41
41
  .nodebb-ezoic-wrap > [id^="ezoic-pub-ad-placeholder-"] {
42
- min-height: 0 !important;
42
+ min-height: 1px !important;
43
43
  }
44
44
 
45
45
  /*