nodebb-plugin-ezoic-infinite 1.4.15 → 1.4.17
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 +11 -28
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -221,6 +221,13 @@
|
|
|
221
221
|
function insertAfter(target, id, kindClass, afterPos) {
|
|
222
222
|
if (!target || !target.insertAdjacentElement) return null;
|
|
223
223
|
if (findWrap(kindClass, afterPos)) return null;
|
|
224
|
+
// CRITICAL: Vérifier qu'aucun placeholder avec cet ID n'existe déjà dans le DOM
|
|
225
|
+
// (peut arriver si deux scheduleRun concurrents recyclent le même ID)
|
|
226
|
+
const existingPh = document.getElementById(`${PLACEHOLDER_PREFIX}${id}`);
|
|
227
|
+
if (existingPh && existingPh.isConnected) {
|
|
228
|
+
// Un placeholder avec cet ID existe déjà - ne pas créer de doublon
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
224
231
|
const wrap = buildWrap(id, kindClass, afterPos);
|
|
225
232
|
target.insertAdjacentElement('afterend', wrap);
|
|
226
233
|
attachFillObserver(wrap, id);
|
|
@@ -339,6 +346,10 @@
|
|
|
339
346
|
if (!id) return;
|
|
340
347
|
if (state.badIds && state.badIds.has(id)) return;
|
|
341
348
|
if (state.retryQueueSet.has(id)) return;
|
|
349
|
+
// Ne pas enqueue si showAds a été appelé récemment (< 2s) pour éviter "already been defined"
|
|
350
|
+
const now = Date.now();
|
|
351
|
+
const last = state.lastShowById.get(id) || 0;
|
|
352
|
+
if (now - last < 2000) return;
|
|
342
353
|
state.retryQueueSet.add(id);
|
|
343
354
|
state.retryQueue.push(id);
|
|
344
355
|
processRetryQueue();
|
|
@@ -680,34 +691,6 @@
|
|
|
680
691
|
}
|
|
681
692
|
|
|
682
693
|
enforceNoAdjacentAds();
|
|
683
|
-
|
|
684
|
-
// Forcer Ezoic à re-scanner les placeholders et recalculer le contenu
|
|
685
|
-
// après insertion de nouveaux wrappers (nécessaire pour infinite scroll)
|
|
686
|
-
if (inserted > 0) {
|
|
687
|
-
try {
|
|
688
|
-
if (window.ezstandalone) {
|
|
689
|
-
if (typeof window.ezstandalone.defineSlots === 'function') {
|
|
690
|
-
window.ezstandalone.defineSlots();
|
|
691
|
-
} else if (typeof window.ezstandalone.refresh === 'function') {
|
|
692
|
-
// Fallback : refresh() via cmd queue pour éviter l'erreur "cannot call refresh"
|
|
693
|
-
window.ezstandalone.cmd = window.ezstandalone.cmd || [];
|
|
694
|
-
window.ezstandalone.cmd.push(() => {
|
|
695
|
-
try {
|
|
696
|
-
if (typeof window.ezstandalone.refresh === 'function') {
|
|
697
|
-
window.ezstandalone.refresh();
|
|
698
|
-
}
|
|
699
|
-
} catch (e) {}
|
|
700
|
-
});
|
|
701
|
-
} else {
|
|
702
|
-
// Aucune méthode de refresh disponible - Ezoic ne recalculera pas le contenu
|
|
703
|
-
console.warn('[Ezoic Plugin] Neither defineSlots nor refresh available - ads may not load on scroll');
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
} catch (e) {
|
|
707
|
-
console.error('[Ezoic Plugin] Error calling Ezoic refresh:', e);
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
|
|
711
694
|
scheduleRefill(250);
|
|
712
695
|
|
|
713
696
|
// If nothing inserted and list isn't in DOM yet (first click), retry a bit
|