nodebb-plugin-ezoic-infinite 1.1.2 → 1.1.4

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 +36 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
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
@@ -31,6 +31,40 @@
31
31
  observers: {},
32
32
  };
33
33
 
34
+ function patchShowAds() {
35
+ try {
36
+ window.ezstandalone = window.ezstandalone || {};
37
+ const ez = window.ezstandalone;
38
+ if (ez.__nodebbEzoicPatched) return;
39
+ if (typeof ez.showAds !== 'function') return;
40
+
41
+ ez.__nodebbEzoicPatched = true;
42
+ const orig = ez.showAds;
43
+
44
+ ez.showAds = function showAdsPatched(arg) {
45
+ if (Array.isArray(arg)) {
46
+ // This batch call is NOT coming from this plugin (we never call showAds with arrays).
47
+ // Split into individual calls to avoid Ezoic loadMore/placeholder issues.
48
+ try {
49
+ if (window.__ezoicInfiniteDebug) {
50
+ console.warn('[ezoic-infinite] showAds(batch) detected. Source stack:', new Error().stack);
51
+ }
52
+ } catch (e) {}
53
+
54
+ const seen = new Set();
55
+ for (const v of arg) {
56
+ const id = parseInt(v, 10);
57
+ if (!Number.isFinite(id) || id <= 0 || seen.has(id)) continue;
58
+ seen.add(id);
59
+ try { orig.call(ez, id); } catch (e) {}
60
+ }
61
+ return;
62
+ }
63
+ return orig.apply(ez, arguments);
64
+ };
65
+ } catch (e) {}
66
+ }
67
+
34
68
  function normalizeBool(v) {
35
69
  return v === true || v === 'true' || v === 1 || v === '1' || v === 'on';
36
70
  }
@@ -444,6 +478,7 @@
444
478
  });
445
479
 
446
480
  $w.on('action:ajaxify.end.ezoicInfinite', () => {
481
+ patchShowAds();
447
482
  run();
448
483
  setTimeout(run, 200);
449
484
  setTimeout(run, 800);
@@ -465,6 +500,7 @@
465
500
  }
466
501
 
467
502
  // Boot
503
+ patchShowAds();
468
504
  cleanupForNewPage();
469
505
  bindNodeBBEvents();
470
506