nodebb-plugin-ezoic-infinite 1.6.65 → 1.6.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/client.js +12 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.6.65",
3
+ "version": "1.6.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
@@ -79,17 +79,12 @@
79
79
  } catch (e) {}
80
80
  }
81
81
 
82
- // ─── CMP/TCF stability ──────────────────────────────────────────────────────
83
- function ensureTcfApiLocator() {
84
- try {
85
- if (typeof window.__tcfapi !== 'function' && typeof window.__cmp !== 'function') return;
86
- if (document.getElementById('__tcfapiLocator')) return;
87
- const f = document.createElement('iframe');
88
- f.style.display = 'none';
89
- f.id = f.name = '__tcfapiLocator';
90
- (document.body || document.documentElement).appendChild(f);
91
- } catch (e) {}
92
- }
82
+ // ensureTcfApiLocator intentionally removed:
83
+ // Creating our own __tcfapiLocator iframe conflicts with the CMP's own locator
84
+ // management and causes "Cannot read properties of null (reading 'postMessage')"
85
+ // errors when the CMP tries to postMessage to an iframe we created then navigated away.
86
+ // The CMP (Ezoic/IAB TCF) handles its own locator iframe lifecycle.
87
+ function ensureTcfApiLocator() { /* no-op */ }
93
88
 
94
89
  // ─── Ezoic min-height tightener ─────────────────────────────────────────────
95
90
  // Ezoic injects `min-height:400px !important` on nested wrappers via inline
@@ -909,23 +904,18 @@
909
904
  const maxInserts = MAX_INSERTS_PER_RUN + (isBoosted() ? 1 : 0);
910
905
  let inserted = 0;
911
906
 
912
- // Viewport top — we never inject after an element that is fully above this.
913
- // This is the definitive guard against NodeBB loading content above the fold
914
- // and our scanner immediately injecting ads on those newly-loaded top items.
915
- // We use a generous negative margin so items just barely scrolled above still
916
- // get ads injected (they'll be visible when the user scrolls back a little).
917
- const viewportSafeTop = -(window.innerHeight || 800) * 0.5;
918
-
919
907
  for (const afterPos of targets) {
920
908
  if (inserted >= maxInserts) break;
921
909
  const el = ordinalMap.get(afterPos);
922
910
  if (!el || !el.isConnected) continue;
923
911
 
924
- // Skip elements that are well above the viewport.
925
- // getBoundingClientRect is cheap on modern engines (no forced layout).
912
+ // Never inject after an element that is fully above the viewport top.
913
+ // This is the definitive guard: NodeBB loads items above the fold when the
914
+ // user scrolls up. Those items have rect.bottom < 0 at the moment of load.
915
+ // Any negative margin ("a little above is ok") still causes the pile-up
916
+ // because NodeBB loads a whole batch just above — we must use exactly 0.
926
917
  try {
927
- const rect = el.getBoundingClientRect();
928
- if (rect.bottom < viewportSafeTop) continue;
918
+ if (el.getBoundingClientRect().bottom < 0) continue;
929
919
  } catch (e) {}
930
920
 
931
921
  if (isAdjacentAd(el)) continue;