nodebb-plugin-ezoic-infinite 1.6.47 → 1.6.48

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 +21 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.6.47",
3
+ "version": "1.6.48",
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
@@ -1700,7 +1700,11 @@ function buildOrdinalMap(items) {
1700
1700
  var BETWEEN_WRAP_SEL = 'div.nodebb-ezoic-wrap.ezoic-ad-between';
1701
1701
  var seen = new WeakMap();
1702
1702
  var io = null;
1703
- var showAdsCooldownUntil = 0;
1703
+ // NOTE: Calling ezstandalone.showAds() was triggering extra bidder requests
1704
+ // (and in your setup, surfacing ServiceWorker/CORS failures) which made
1705
+ // fills slower and created visible repositioning. We only do a tiny scroll
1706
+ // nudge here, because manual micro-scroll reliably triggers a fill.
1707
+ var microScrollCooldownUntil = 0;
1704
1708
 
1705
1709
  function now() { return Date.now ? Date.now() : +new Date(); }
1706
1710
 
@@ -1721,21 +1725,24 @@ function buildOrdinalMap(items) {
1721
1725
  return false;
1722
1726
  }
1723
1727
 
1724
- function safeShowAds() {
1728
+ function microScrollNudge() {
1725
1729
  var t = now();
1726
- if (t < showAdsCooldownUntil) return;
1727
- showAdsCooldownUntil = t + 1200;
1730
+ if (t < microScrollCooldownUntil) return;
1731
+ microScrollCooldownUntil = t + 1200;
1728
1732
 
1733
+ // Prefer a real 1px scroll + restore: this matches the observed manual fix.
1729
1734
  try {
1730
- if (window.ezstandalone && typeof window.ezstandalone.showAds === 'function') {
1731
- window.ezstandalone.showAds();
1732
- return;
1733
- }
1735
+ var y = window.pageYOffset || document.documentElement.scrollTop || 0;
1736
+ window.scrollTo(0, y + 1);
1737
+ (window.requestAnimationFrame || setTimeout)(function () {
1738
+ try { window.scrollTo(0, y); } catch (e) {}
1739
+ try { window.dispatchEvent(new Event('scroll')); } catch (e) {}
1740
+ }, 16);
1741
+ return;
1734
1742
  } catch (e) {}
1735
1743
 
1736
- // Fallback: nudge common listeners.
1744
+ // Fallback: nudge listeners.
1737
1745
  try { window.dispatchEvent(new Event('scroll')); } catch (e) {}
1738
- try { window.dispatchEvent(new Event('resize')); } catch (e) {}
1739
1746
  }
1740
1747
 
1741
1748
  function scheduleCheck(wrap) {
@@ -1759,17 +1766,16 @@ function buildOrdinalMap(items) {
1759
1766
 
1760
1767
  if (hasAnyCreative(wrap)) return;
1761
1768
 
1762
- // Still empty -> poke.
1769
+ // Still empty -> poke (micro-scroll only; no showAds/refresh calls).
1763
1770
  var id = getSlotId(wrap) || 'none';
1764
1771
  try { console.log('[EZ EMPTY]', id); } catch (e) {}
1765
- safeShowAds();
1772
+ microScrollNudge();
1766
1773
 
1767
- // One more re-check shortly after the poke.
1774
+ // Re-check once after the nudge, but do not loop.
1768
1775
  setTimeout(function () {
1769
1776
  if (!wrap.isConnected) return;
1770
1777
  if (hasAnyCreative(wrap)) return;
1771
- // If still empty after a poke, try once more (but do not loop forever).
1772
- safeShowAds();
1778
+ // Still empty: leave it to the native pipeline; avoid repeated nudges.
1773
1779
  }, 900);
1774
1780
  } catch (e) {}
1775
1781
  }