nodebb-plugin-ezoic-infinite 1.4.69 → 1.4.70
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 +19 -5
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
const PH_PREFIX = 'ezoic-pub-ad-placeholder-';
|
|
21
21
|
|
|
22
22
|
const MAX_INSERTS_PER_TICK = 3;
|
|
23
|
-
|
|
23
|
+
// Ezoic can be late to render on ajaxified pages; keep wrappers around a bit longer
|
|
24
|
+
// (they are hidden until filled anyway, so no visual blank space).
|
|
25
|
+
const FILL_TIMEOUT_MS = 8000;
|
|
24
26
|
const RECYCLE_MARGIN_PX = 600;
|
|
25
27
|
const SHOW_DEBOUNCE_MS = 500;
|
|
26
28
|
|
|
@@ -202,10 +204,22 @@
|
|
|
202
204
|
if (now() - last < SHOW_DEBOUNCE_MS) return;
|
|
203
205
|
state.lastShowById.set(id, now());
|
|
204
206
|
|
|
205
|
-
|
|
207
|
+
// Capture current page key so queued calls don't fire on the next ajaxify page.
|
|
208
|
+
const expectedPageKey = state.pageKey;
|
|
209
|
+
|
|
210
|
+
const safeCall = () => {
|
|
206
211
|
try {
|
|
212
|
+
// Only attempt if we're still on the same page and the placeholder exists *now*.
|
|
213
|
+
if (expectedPageKey !== state.pageKey) return;
|
|
214
|
+
const el = document.getElementById(`${PH_PREFIX}${id}`);
|
|
215
|
+
if (!el) return;
|
|
207
216
|
if (window.ezstandalone && typeof window.ezstandalone.showAds === 'function') {
|
|
208
|
-
|
|
217
|
+
// Let the DOM settle one frame (helps with ajaxify/morphdom timing)
|
|
218
|
+
requestAnimationFrame(() => {
|
|
219
|
+
if (expectedPageKey !== state.pageKey) return;
|
|
220
|
+
if (!document.getElementById(`${PH_PREFIX}${id}`)) return;
|
|
221
|
+
window.ezstandalone.showAds(id);
|
|
222
|
+
});
|
|
209
223
|
}
|
|
210
224
|
} catch (e) {}
|
|
211
225
|
};
|
|
@@ -213,8 +227,8 @@
|
|
|
213
227
|
try {
|
|
214
228
|
window.ezstandalone = window.ezstandalone || {};
|
|
215
229
|
window.ezstandalone.cmd = window.ezstandalone.cmd || [];
|
|
216
|
-
if (typeof window.ezstandalone.showAds === 'function')
|
|
217
|
-
else window.ezstandalone.cmd.push(
|
|
230
|
+
if (typeof window.ezstandalone.showAds === 'function') safeCall();
|
|
231
|
+
else window.ezstandalone.cmd.push(safeCall);
|
|
218
232
|
} catch (e) {}
|
|
219
233
|
}
|
|
220
234
|
|