nodebb-plugin-ezoic-infinite 1.5.3 → 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 +36 -40
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
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 || [];
|
|
5
2
|
/**
|
|
6
3
|
* Ezoic Infinite Ads for NodeBB 4.x
|
|
7
4
|
* - Event-driven only (ajaxify hooks + MutationObserver + IntersectionObserver)
|
|
@@ -13,6 +10,15 @@ window._ezaq = window._ezaq || [];
|
|
|
13
10
|
(function () {
|
|
14
11
|
const CFG_URL = '/api/plugins/ezoic-infinite/config';
|
|
15
12
|
|
|
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
|
+
}
|
|
19
|
+
|
|
20
|
+
bootEzGlobals();
|
|
21
|
+
|
|
16
22
|
// -------------------------
|
|
17
23
|
// Utilities
|
|
18
24
|
// -------------------------
|
|
@@ -81,48 +87,39 @@ window._ezaq = window._ezaq || [];
|
|
|
81
87
|
return args.flat().map(String);
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
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
|
+
}
|
|
86
98
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
99
|
+
function safeShowAds(ids) {
|
|
100
|
+
ensureEzGlobals();
|
|
101
|
+
const show = (window.ezstandalone && typeof window.ezstandalone.showAds === 'function')
|
|
102
|
+
? window.ezstandalone.showAds
|
|
103
|
+
: null;
|
|
90
104
|
|
|
91
|
-
|
|
92
|
-
// Ensure placeholder exists somewhere (pool), so ez-standalone won't log "does not exist"
|
|
93
|
-
Pool.ensurePlaceholder(id);
|
|
94
|
-
|
|
95
|
-
const el = document.getElementById(id);
|
|
96
|
-
if (el && document.body.contains(el)) {
|
|
97
|
-
try {
|
|
98
|
-
// Call one-by-one to avoid batch logging on missing nodes
|
|
99
|
-
original.call(window.ezstandalone, id);
|
|
100
|
-
} catch (e) {
|
|
101
|
-
// swallow: Ezoic can throw if called during transitions
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
};
|
|
105
|
+
if (!show) return;
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
for (const id of ids) {
|
|
108
|
+
Pool.ensurePlaceholder(id);
|
|
109
|
+
const el = document.getElementById(id);
|
|
110
|
+
if (!el) continue;
|
|
111
|
+
|
|
112
|
+
// Don't render into the hidden pool (would be invisible, and can confuse Ezoic)
|
|
113
|
+
if (el.closest('#ezoic-placeholder-pool')) continue;
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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);
|
|
115
|
+
if (!document.body.contains(el)) continue;
|
|
116
|
+
|
|
117
|
+
try { show.call(window.ezstandalone, id); } catch (e) {}
|
|
122
118
|
}
|
|
123
119
|
}
|
|
124
120
|
|
|
125
|
-
|
|
121
|
+
function ezCmd(fn) {
|
|
122
|
+
|
|
126
123
|
// Tokenize so queued callbacks don't run after navigation
|
|
127
124
|
const tokenAtSchedule = navToken;
|
|
128
125
|
window.ezstandalone = window.ezstandalone || {};
|
|
@@ -218,7 +215,6 @@ function installShowAdsHook() {
|
|
|
218
215
|
|
|
219
216
|
if (c.excluded) return; // HARD stop: never inject for excluded users
|
|
220
217
|
|
|
221
|
-
installShowAdsHook();
|
|
222
218
|
this.initObservers();
|
|
223
219
|
|
|
224
220
|
if (c.enableBetweenAds) this.injectBetweenTopics(c);
|
|
@@ -365,7 +361,7 @@ function installShowAdsHook() {
|
|
|
365
361
|
|
|
366
362
|
// First load
|
|
367
363
|
once('DOMContentLoaded', () => {
|
|
368
|
-
|
|
364
|
+
|
|
369
365
|
prefetchConfig();
|
|
370
366
|
Ad.scheduleScan();
|
|
371
367
|
});
|