nodebb-plugin-ezoic-infinite 1.4.40 → 1.4.41
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 +12 -22
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
timer: null,
|
|
40
40
|
|
|
41
41
|
obs: null,
|
|
42
|
+
canShowAds: true,
|
|
43
|
+
activeTimeouts: new Set(),
|
|
42
44
|
lastScrollRun: 0,
|
|
43
45
|
__scrollBound: false,
|
|
44
46
|
};
|
|
@@ -325,10 +327,6 @@
|
|
|
325
327
|
|
|
326
328
|
function callShowAdsWhenReady(id) {
|
|
327
329
|
if (!id) return;
|
|
328
|
-
|
|
329
|
-
if (window.location.pathname !== '/') {
|
|
330
|
-
console.log('[TIMING] callShowAdsWhenReady ID:', id);
|
|
331
|
-
}
|
|
332
330
|
|
|
333
331
|
const now = Date.now(), last = state.lastShowById.get(id) || 0;
|
|
334
332
|
if (now - last < 3500) return;
|
|
@@ -352,23 +350,16 @@
|
|
|
352
350
|
if (state.pageKey !== startPageKey) return;
|
|
353
351
|
// Abort if another concurrent call is already handling this id
|
|
354
352
|
if (state.pendingById.has(id)) return;
|
|
355
|
-
|
|
353
|
+
|
|
356
354
|
attempts += 1;
|
|
357
355
|
const el = document.getElementById(phId);
|
|
358
356
|
if (el && el.isConnected) {
|
|
359
|
-
if (window.location.pathname !== '/') {
|
|
360
|
-
console.log('[TIMING] Placeholder', id, 'trouvé dans DOM, appel showAds');
|
|
361
|
-
}
|
|
362
|
-
|
|
363
357
|
// Double-check pageKey juste avant doCall (au cas où cleanup appelé entre-temps)
|
|
364
358
|
if (state.pageKey !== startPageKey) {
|
|
365
|
-
if (window.location.pathname !== '/') {
|
|
366
|
-
console.log('[TIMING] ABORT ID', id, '- navigation détectée avant showAds');
|
|
367
|
-
}
|
|
368
359
|
// Note: les timeouts seront nettoyés par cleanup()
|
|
369
360
|
return;
|
|
370
361
|
}
|
|
371
|
-
|
|
362
|
+
|
|
372
363
|
// Si doCall() réussit, Ezoic est chargé et showAds a été appelé → sortir
|
|
373
364
|
if (doCall()) {
|
|
374
365
|
state.pendingById.delete(id);
|
|
@@ -564,9 +555,9 @@
|
|
|
564
555
|
// showAds() continuent à s'exécuter après la navigation
|
|
565
556
|
state.activeTimeouts.forEach(id => clearTimeout(id));
|
|
566
557
|
state.activeTimeouts.clear();
|
|
567
|
-
|
|
558
|
+
|
|
568
559
|
if (state.obs) { state.obs.disconnect(); state.obs = null; }
|
|
569
|
-
state.
|
|
560
|
+
state.canShowAds = false;
|
|
570
561
|
state.scheduled = false;
|
|
571
562
|
clearTimeout(state.timer);
|
|
572
563
|
state.timer = null;
|
|
@@ -580,10 +571,10 @@
|
|
|
580
571
|
|
|
581
572
|
async function runCore() {
|
|
582
573
|
// Attendre que canInsert soit true (protection race condition navigation)
|
|
583
|
-
if (!state.
|
|
574
|
+
if (!state.canShowAds) {
|
|
584
575
|
return;
|
|
585
576
|
}
|
|
586
|
-
|
|
577
|
+
|
|
587
578
|
patchShowAds();
|
|
588
579
|
|
|
589
580
|
const cfg = await fetchConfig();
|
|
@@ -622,7 +613,6 @@
|
|
|
622
613
|
|
|
623
614
|
enforceNoAdjacentAds();
|
|
624
615
|
|
|
625
|
-
|
|
626
616
|
// If nothing inserted and list isn't in DOM yet (first click), retry a bit
|
|
627
617
|
let count = 0;
|
|
628
618
|
if (kind === 'topic') count = getPostContainers().length;
|
|
@@ -673,14 +663,14 @@
|
|
|
673
663
|
$(window).on('action:ajaxify.end.ezoicInfinite', () => {
|
|
674
664
|
state.pageKey = getPageKey();
|
|
675
665
|
ensureObserver();
|
|
676
|
-
|
|
666
|
+
|
|
677
667
|
// CRITIQUE: Attendre 300ms avant de permettre l'insertion de nouveaux placeholders
|
|
678
668
|
// pour laisser les anciens showAds() (en cours) se terminer ou échouer proprement
|
|
679
669
|
// Sinon race condition: NodeBB vide le DOM pendant que Ezoic essaie d'accéder aux placeholders
|
|
680
|
-
state.
|
|
670
|
+
state.canShowAds = false;
|
|
681
671
|
setTimeout(() => {
|
|
682
|
-
state.
|
|
683
|
-
},
|
|
672
|
+
state.canShowAds = true;
|
|
673
|
+
}, 500);
|
|
684
674
|
});
|
|
685
675
|
|
|
686
676
|
$(window).on('action:category.loaded.ezoicInfinite', () => {
|