nodebb-plugin-ezoic-infinite 1.4.33 → 1.4.34
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 +60 -7
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -642,30 +642,42 @@
|
|
|
642
642
|
$(window).on('action:ajaxify.end.ezoicInfinite', () => {
|
|
643
643
|
state.pageKey = getPageKey();
|
|
644
644
|
ensureObserver();
|
|
645
|
-
|
|
646
|
-
//
|
|
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) {}
|
|
647
659
|
});
|
|
648
660
|
|
|
649
661
|
$(window).on('action:category.loaded.ezoicInfinite', () => {
|
|
650
662
|
ensureObserver();
|
|
651
663
|
// category.loaded = infinite scroll, Ezoic déjà chargé normalement
|
|
652
|
-
|
|
664
|
+
waitForContentThenRun();
|
|
653
665
|
});
|
|
654
666
|
|
|
655
667
|
$(window).on('action:topics.loaded.ezoicInfinite', () => {
|
|
656
668
|
ensureObserver();
|
|
657
|
-
|
|
669
|
+
waitForContentThenRun();
|
|
658
670
|
});
|
|
659
671
|
|
|
660
672
|
$(window).on('action:topic.loaded.ezoicInfinite', () => {
|
|
661
673
|
ensureObserver();
|
|
662
|
-
|
|
674
|
+
waitForContentThenRun();
|
|
663
675
|
});
|
|
664
676
|
|
|
665
677
|
$(window).on('action:posts.loaded.ezoicInfinite', () => {
|
|
666
678
|
ensureObserver();
|
|
667
679
|
// posts.loaded = infinite scroll
|
|
668
|
-
|
|
680
|
+
waitForContentThenRun();
|
|
669
681
|
});
|
|
670
682
|
}
|
|
671
683
|
|
|
@@ -689,6 +701,47 @@
|
|
|
689
701
|
}, { passive: true });
|
|
690
702
|
}
|
|
691
703
|
|
|
704
|
+
|
|
705
|
+
// Fonction qui attend que la page ait assez de contenu avant d'insérer les pubs
|
|
706
|
+
function waitForContentThenRun() {
|
|
707
|
+
const MIN_WORDS = 250;
|
|
708
|
+
let attempts = 0;
|
|
709
|
+
const maxAttempts = 20; // 20 × 200ms = 4s max
|
|
710
|
+
|
|
711
|
+
(function check() {
|
|
712
|
+
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
|
+
|
|
723
|
+
// Compter les mots sur la page
|
|
724
|
+
const text = document.body.innerText || '';
|
|
725
|
+
const wordCount = text.split(/\s+/).filter(Boolean).length;
|
|
726
|
+
|
|
727
|
+
if (wordCount >= MIN_WORDS) {
|
|
728
|
+
// Assez de contenu → lancer l'insertion
|
|
729
|
+
scheduleRun();
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// Pas assez de contenu
|
|
734
|
+
if (attempts >= maxAttempts) {
|
|
735
|
+
// Timeout après 4s → tenter quand même
|
|
736
|
+
scheduleRun();
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
// Réessayer dans 200ms
|
|
741
|
+
setTimeout(check, 200);
|
|
742
|
+
})();
|
|
743
|
+
}
|
|
744
|
+
|
|
692
745
|
// Fonction qui attend que Ezoic soit vraiment chargé
|
|
693
746
|
function waitForEzoicThenRun() {
|
|
694
747
|
let attempts = 0;
|
|
@@ -700,7 +753,7 @@
|
|
|
700
753
|
if (window.ezstandalone && typeof window.ezstandalone.showAds === 'function') {
|
|
701
754
|
// Ezoic est prêt → lancer l'insertion
|
|
702
755
|
scheduleRun();
|
|
703
|
-
|
|
756
|
+
waitForContentThenRun();
|
|
704
757
|
return;
|
|
705
758
|
}
|
|
706
759
|
// Ezoic pas encore prêt
|