nodebb-plugin-ezoic-infinite 1.4.52 → 1.4.54
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 +35 -41
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
'use strict';
|
|
3
|
-
console.log('[PLUGIN] Ezoic plugin loading...');
|
|
4
|
-
|
|
5
3
|
const $ = (typeof window.jQuery === 'function') ? window.jQuery : null;
|
|
6
|
-
console.log('[PLUGIN] jQuery:', !!$);
|
|
7
|
-
|
|
8
4
|
const SELECTORS = {
|
|
9
5
|
topicItem: 'li[component="category/topic"]',
|
|
10
6
|
postItem: '[component="post"][data-pid]',
|
|
@@ -37,9 +33,7 @@
|
|
|
37
33
|
|
|
38
34
|
obs: null,
|
|
39
35
|
activeTimeouts: new Set(),
|
|
40
|
-
lastScrollRun: 0,
|
|
41
|
-
__scrollBound: false,
|
|
42
|
-
};
|
|
36
|
+
lastScrollRun: 0, };
|
|
43
37
|
|
|
44
38
|
function normalizeBool(v) {
|
|
45
39
|
return v === true || v === 'true' || v === 1 || v === '1' || v === 'on';
|
|
@@ -483,9 +477,7 @@
|
|
|
483
477
|
|
|
484
478
|
if (findWrap(kindClass, afterPos)) continue;
|
|
485
479
|
|
|
486
|
-
const
|
|
487
|
-
: (kindClass === 'ezoic-ad-message') ? state.liveMessage
|
|
488
|
-
: state.liveCategory, pick = pickId(kindPool, liveArr);
|
|
480
|
+
const pick = pickId(kindPool, []);
|
|
489
481
|
const id = pick.id;
|
|
490
482
|
if (!id) break;
|
|
491
483
|
|
|
@@ -555,9 +547,14 @@
|
|
|
555
547
|
}
|
|
556
548
|
|
|
557
549
|
function cleanup() {
|
|
558
|
-
console.log('[CLEANUP] Called - navigation started');
|
|
559
550
|
destroyUsedPlaceholders();
|
|
560
551
|
|
|
552
|
+
// CRITIQUE: Supprimer TOUS les wrappers .ezoic-ad du DOM
|
|
553
|
+
// Sinon ils restent et deviennent "unused" sur la nouvelle page
|
|
554
|
+
document.querySelectorAll('.ezoic-ad').forEach(el => {
|
|
555
|
+
try { el.remove(); } catch (e) {}
|
|
556
|
+
});
|
|
557
|
+
|
|
561
558
|
state.pageKey = getPageKey();
|
|
562
559
|
state.cfg = null;
|
|
563
560
|
state.cfgPromise = null;
|
|
@@ -688,7 +685,6 @@
|
|
|
688
685
|
function bind() {
|
|
689
686
|
if (!$) return;
|
|
690
687
|
|
|
691
|
-
console.log('[PLUGIN] Unbinding old hooks');
|
|
692
688
|
$(window).off('.ezoicInfinite');
|
|
693
689
|
|
|
694
690
|
$(window).on('action:ajaxify.start.ezoicInfinite', () => cleanup());
|
|
@@ -708,8 +704,6 @@
|
|
|
708
704
|
// category.loaded = infinite scroll, Ezoic déjà chargé normalement
|
|
709
705
|
waitForContentThenRun();
|
|
710
706
|
});
|
|
711
|
-
console.log('[PLUGIN] Hooks registered:', 'ajaxify.start', 'ajaxify.end', 'category.loaded', 'topics.loaded', 'topic.loaded', 'posts.loaded');
|
|
712
|
-
|
|
713
707
|
$(window).on('action:topics.loaded.ezoicInfinite', () => {
|
|
714
708
|
ensureObserver();
|
|
715
709
|
waitForContentThenRun();
|
|
@@ -749,33 +743,33 @@
|
|
|
749
743
|
|
|
750
744
|
// Fonction qui attend que la page ait assez de contenu avant d'insérer les pubs
|
|
751
745
|
function waitForContentThenRun() {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
746
|
+
const MIN_WORDS = 250;
|
|
747
|
+
let attempts = 0;
|
|
748
|
+
const maxAttempts = 20; // 20 × 200ms = 4s max
|
|
749
|
+
|
|
750
|
+
(function check() {
|
|
751
|
+
attempts++;
|
|
752
|
+
|
|
753
|
+
// Compter les mots sur la page
|
|
754
|
+
const text = document.body.innerText || '';
|
|
755
|
+
const wordCount = text.split(/\s+/).filter(Boolean).length;
|
|
756
|
+
|
|
757
|
+
if (wordCount >= MIN_WORDS) {
|
|
758
|
+
// Assez de contenu → lancer l'insertion
|
|
759
|
+
scheduleRun();
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// Pas assez de contenu
|
|
764
|
+
if (attempts >= maxAttempts) {
|
|
765
|
+
// Timeout après 4s → tenter quand même
|
|
766
|
+
scheduleRun();
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// Réessayer dans 200ms
|
|
771
|
+
setTimeout(check, 200);
|
|
772
|
+
})();
|
|
779
773
|
}
|
|
780
774
|
|
|
781
775
|
// Fonction qui attend que Ezoic soit vraiment chargé
|