nodebb-plugin-ezoic-infinite 1.5.2 → 1.5.3

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 +15 -35
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
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,4 +1,7 @@
1
1
  'use strict';
2
+
3
+ // Safety stub: some Ezoic scripts expect a global queue even when ads are disabled
4
+ window._ezaq = window._ezaq || [];
2
5
  /**
3
6
  * Ezoic Infinite Ads for NodeBB 4.x
4
7
  * - Event-driven only (ajaxify hooks + MutationObserver + IntersectionObserver)
@@ -8,13 +11,6 @@
8
11
  */
9
12
 
10
13
  (function () {
11
-
12
- // --- Safety stubs: prevent `_ezaq` crashes even when ads are disabled/excluded ---
13
- // IMPORTANT: do NOT create a fake `showAds` function, it can confuse Ezoic's loader.
14
- window._ezaq = window._ezaq || [];
15
- window.ezstandalone = window.ezstandalone || {};
16
- window.ezstandalone.cmd = window.ezstandalone.cmd || [];
17
-
18
14
  const CFG_URL = '/api/plugins/ezoic-infinite/config';
19
15
 
20
16
  // -------------------------
@@ -112,35 +108,19 @@ window.ezstandalone.cmd = window.ezstandalone.cmd || [];
112
108
  return wrapped;
113
109
  }
114
110
 
115
- function installShowAdsHook() {
116
- // If ezstandalone already exists, wrap now.
117
- if (window.ezstandalone && window.ezstandalone.showAds) {
118
- window.ezstandalone.showAds = wrapShowAds(window.ezstandalone.showAds);
119
- }
120
-
121
- // Hook future assignment (no polling)
122
- try {
123
- if (!window.ezstandalone) window.ezstandalone = {};
124
- const ez = window.ezstandalone;
125
-
126
- // If already has a setter installed, do nothing
127
- const desc = Object.getOwnPropertyDescriptor(ez, 'showAds');
128
- if (desc && (desc.set || desc.get)) return;
129
-
130
- let _showAds = ez.showAds;
131
- Object.defineProperty(ez, 'showAds', {
132
- configurable: true,
133
- enumerable: true,
134
- get() { return _showAds; },
135
- set(v) { _showAds = wrapShowAds(v); }
136
- });
137
-
138
- // Re-assign current value through setter
139
- ez.showAds = _showAds;
140
- } catch (e) {
141
- // If defineProperty fails, best-effort wrap is still in place above.
142
- }
111
+
112
+ function installShowAdsHook() {
113
+ // NOTE: Do NOT use Object.defineProperty accessor tricks on `ezstandalone.showAds`.
114
+ // Ezoic's standalone loader may validate that property as a plain writable function,
115
+ // and accessor hooks can cause `defineScript failed` / `displayScript failed`.
116
+ // Instead, we only wrap it once it exists (event-driven paths will call this again).
117
+ const ez = window.ezstandalone;
118
+ if (!ez) return;
119
+ if (!Array.isArray(ez.cmd)) ez.cmd = [];
120
+ if (typeof ez.showAds === 'function' && !ez.showAds.__ezoicInfiniteWrapped) {
121
+ ez.showAds = wrapShowAds(ez.showAds);
143
122
  }
123
+ }
144
124
 
145
125
  function ezCmd(fn) {
146
126
  // Tokenize so queued callbacks don't run after navigation