nodebb-plugin-ezoic-infinite 1.4.34 → 1.4.36
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 +6 -33
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -10,12 +10,9 @@
|
|
|
10
10
|
}, WRAP_CLASS = 'ezoic-ad';
|
|
11
11
|
const PLACEHOLDER_PREFIX = 'ezoic-pub-ad-placeholder-', MAX_INSERTS_PER_RUN = 3;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
13
|
// Nécessaire pour savoir si on doit appeler destroyPlaceholders avant recyclage.
|
|
16
14
|
const sessionDefinedIds = new Set();
|
|
17
15
|
|
|
18
|
-
|
|
19
16
|
const insertingIds = new Set(), state = {
|
|
20
17
|
pageKey: null,
|
|
21
18
|
cfg: null,
|
|
@@ -589,9 +586,9 @@
|
|
|
589
586
|
}
|
|
590
587
|
}
|
|
591
588
|
|
|
592
|
-
|
|
593
589
|
enforceNoAdjacentAds();
|
|
594
590
|
|
|
591
|
+
|
|
595
592
|
// If nothing inserted and list isn't in DOM yet (first click), retry a bit
|
|
596
593
|
let count = 0;
|
|
597
594
|
if (kind === 'topic') count = getPostContainers().length;
|
|
@@ -642,20 +639,6 @@
|
|
|
642
639
|
$(window).on('action:ajaxify.end.ezoicInfinite', () => {
|
|
643
640
|
state.pageKey = getPageKey();
|
|
644
641
|
ensureObserver();
|
|
645
|
-
|
|
646
|
-
// CRITIQUE : Forcer Ezoic à recalculer le word count après navigation
|
|
647
|
-
try {
|
|
648
|
-
if (window.ezstandalone) {
|
|
649
|
-
// Méthode 1 : fireEvent pour notifier la navigation AJAX
|
|
650
|
-
if (typeof window.ezstandalone.fireEvent === 'function') {
|
|
651
|
-
window.ezstandalone.fireEvent('ajax');
|
|
652
|
-
}
|
|
653
|
-
// Méthode 2 : refresh force un recalcul complet
|
|
654
|
-
if (typeof window.ezstandalone.refresh === 'function') {
|
|
655
|
-
window.ezstandalone.refresh();
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
} catch (e) {}
|
|
659
642
|
});
|
|
660
643
|
|
|
661
644
|
$(window).on('action:category.loaded.ezoicInfinite', () => {
|
|
@@ -701,42 +684,32 @@
|
|
|
701
684
|
}, { passive: true });
|
|
702
685
|
}
|
|
703
686
|
|
|
704
|
-
|
|
705
687
|
// Fonction qui attend que la page ait assez de contenu avant d'insérer les pubs
|
|
706
688
|
function waitForContentThenRun() {
|
|
707
689
|
const MIN_WORDS = 250;
|
|
708
690
|
let attempts = 0;
|
|
709
691
|
const maxAttempts = 20; // 20 × 200ms = 4s max
|
|
710
|
-
|
|
692
|
+
|
|
711
693
|
(function check() {
|
|
712
694
|
attempts++;
|
|
713
|
-
|
|
714
|
-
// Forcer Ezoic à recalculer avant de vérifier (première tentative seulement)
|
|
715
|
-
if (attempts === 1) {
|
|
716
|
-
try {
|
|
717
|
-
if (window.ezstandalone && typeof window.ezstandalone.refresh === 'function') {
|
|
718
|
-
window.ezstandalone.refresh();
|
|
719
|
-
}
|
|
720
|
-
} catch (e) {}
|
|
721
|
-
}
|
|
722
|
-
|
|
695
|
+
|
|
723
696
|
// Compter les mots sur la page
|
|
724
697
|
const text = document.body.innerText || '';
|
|
725
698
|
const wordCount = text.split(/\s+/).filter(Boolean).length;
|
|
726
|
-
|
|
699
|
+
|
|
727
700
|
if (wordCount >= MIN_WORDS) {
|
|
728
701
|
// Assez de contenu → lancer l'insertion
|
|
729
702
|
scheduleRun();
|
|
730
703
|
return;
|
|
731
704
|
}
|
|
732
|
-
|
|
705
|
+
|
|
733
706
|
// Pas assez de contenu
|
|
734
707
|
if (attempts >= maxAttempts) {
|
|
735
708
|
// Timeout après 4s → tenter quand même
|
|
736
709
|
scheduleRun();
|
|
737
710
|
return;
|
|
738
711
|
}
|
|
739
|
-
|
|
712
|
+
|
|
740
713
|
// Réessayer dans 200ms
|
|
741
714
|
setTimeout(check, 200);
|
|
742
715
|
})();
|