nodebb-plugin-ezoic-infinite 1.5.2 → 1.5.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.
- package/package.json +1 -1
- package/public/client.js +34 -58
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -8,14 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
(function () {
|
|
11
|
+
const CFG_URL = '/api/plugins/ezoic-infinite/config';
|
|
11
12
|
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
window._ezaq = window._ezaq || [];
|
|
15
|
-
window.ezstandalone = window.ezstandalone || {};
|
|
16
|
-
window.ezstandalone.cmd = window.ezstandalone.cmd || [];
|
|
13
|
+
// Ensure Ezoic globals exist early (prevents `cmd`/`_ezaq` crashes)
|
|
14
|
+
function bootEzGlobals(){
|
|
15
|
+
window._ezaq = window._ezaq || [];
|
|
16
|
+
window.ezstandalone = window.ezstandalone || {};
|
|
17
|
+
window.ezstandalone.cmd = window.ezstandalone.cmd || [];
|
|
18
|
+
}
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
bootEzGlobals();
|
|
19
21
|
|
|
20
22
|
// -------------------------
|
|
21
23
|
// Utilities
|
|
@@ -85,64 +87,39 @@ window.ezstandalone.cmd = window.ezstandalone.cmd || [];
|
|
|
85
87
|
return args.flat().map(String);
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
// -------------------------
|
|
91
|
+
// Ezoic safe calls (no defineProperty hooks)
|
|
92
|
+
// -------------------------
|
|
93
|
+
function ensureEzGlobals() {
|
|
94
|
+
window._ezaq = window._ezaq || [];
|
|
95
|
+
window.ezstandalone = window.ezstandalone || {};
|
|
96
|
+
window.ezstandalone.cmd = window.ezstandalone.cmd || [];
|
|
97
|
+
}
|
|
90
98
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
function safeShowAds(ids) {
|
|
100
|
+
ensureEzGlobals();
|
|
101
|
+
const show = (window.ezstandalone && typeof window.ezstandalone.showAds === 'function')
|
|
102
|
+
? window.ezstandalone.showAds
|
|
103
|
+
: null;
|
|
94
104
|
|
|
95
|
-
|
|
96
|
-
// Ensure placeholder exists somewhere (pool), so ez-standalone won't log "does not exist"
|
|
97
|
-
Pool.ensurePlaceholder(id);
|
|
98
|
-
|
|
99
|
-
const el = document.getElementById(id);
|
|
100
|
-
if (el && document.body.contains(el)) {
|
|
101
|
-
try {
|
|
102
|
-
// Call one-by-one to avoid batch logging on missing nodes
|
|
103
|
-
original.call(window.ezstandalone, id);
|
|
104
|
-
} catch (e) {
|
|
105
|
-
// swallow: Ezoic can throw if called during transitions
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
105
|
+
if (!show) return;
|
|
110
106
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
for (const id of ids) {
|
|
108
|
+
Pool.ensurePlaceholder(id);
|
|
109
|
+
const el = document.getElementById(id);
|
|
110
|
+
if (!el) continue;
|
|
114
111
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (window.ezstandalone && window.ezstandalone.showAds) {
|
|
118
|
-
window.ezstandalone.showAds = wrapShowAds(window.ezstandalone.showAds);
|
|
119
|
-
}
|
|
112
|
+
// Don't render into the hidden pool (would be invisible, and can confuse Ezoic)
|
|
113
|
+
if (el.closest('#ezoic-placeholder-pool')) continue;
|
|
120
114
|
|
|
121
|
-
|
|
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
|
-
});
|
|
115
|
+
if (!document.body.contains(el)) continue;
|
|
137
116
|
|
|
138
|
-
|
|
139
|
-
ez.showAds = _showAds;
|
|
140
|
-
} catch (e) {
|
|
141
|
-
// If defineProperty fails, best-effort wrap is still in place above.
|
|
142
|
-
}
|
|
117
|
+
try { show.call(window.ezstandalone, id); } catch (e) {}
|
|
143
118
|
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function ezCmd(fn) {
|
|
144
122
|
|
|
145
|
-
function ezCmd(fn) {
|
|
146
123
|
// Tokenize so queued callbacks don't run after navigation
|
|
147
124
|
const tokenAtSchedule = navToken;
|
|
148
125
|
window.ezstandalone = window.ezstandalone || {};
|
|
@@ -238,7 +215,6 @@ window.ezstandalone.cmd = window.ezstandalone.cmd || [];
|
|
|
238
215
|
|
|
239
216
|
if (c.excluded) return; // HARD stop: never inject for excluded users
|
|
240
217
|
|
|
241
|
-
installShowAdsHook();
|
|
242
218
|
this.initObservers();
|
|
243
219
|
|
|
244
220
|
if (c.enableBetweenAds) this.injectBetweenTopics(c);
|
|
@@ -385,7 +361,7 @@ window.ezstandalone.cmd = window.ezstandalone.cmd || [];
|
|
|
385
361
|
|
|
386
362
|
// First load
|
|
387
363
|
once('DOMContentLoaded', () => {
|
|
388
|
-
|
|
364
|
+
|
|
389
365
|
prefetchConfig();
|
|
390
366
|
Ad.scheduleScan();
|
|
391
367
|
});
|