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.
- package/package.json +1 -1
- package/public/client.js +15 -35
package/package.json
CHANGED
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|