nodebb-plugin-ezoic-infinite 1.8.3 → 1.8.4
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 +53 -2
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -89,6 +89,10 @@
|
|
|
89
89
|
const MAX_DESTROY_BATCH = 4; // ids max par destroyPlaceholders(...ids)
|
|
90
90
|
const DESTROY_FLUSH_MS = 30; // micro-buffer destroy pour lisser les rafales
|
|
91
91
|
const BURST_COOLDOWN_MS = 120; // délai min entre deux déclenchements de burst
|
|
92
|
+
const PAGE_WARMUP_MS = 700; // laisse NodeBB rendre le contenu avant les premiers showAds
|
|
93
|
+
const CONTENT_SETTLE_WINDOW_MS = 350;
|
|
94
|
+
const CONTENT_SETTLE_MAX_DELAY_MS = 1500;
|
|
95
|
+
const CONTENT_GROWTH_THRESHOLD_PX = 120;
|
|
92
96
|
|
|
93
97
|
// Marges IO larges et fixes — observer créé une seule fois au boot
|
|
94
98
|
const IO_MARGIN_DESKTOP = '2500px 0px 2500px 0px';
|
|
@@ -149,6 +153,10 @@
|
|
|
149
153
|
burstDeadline: 0,
|
|
150
154
|
burstCount: 0,
|
|
151
155
|
lastBurstTs: 0,
|
|
156
|
+
pageWarmUntil: 0,
|
|
157
|
+
settleDelaySince: 0,
|
|
158
|
+
contentSampleH: 0,
|
|
159
|
+
contentSampleTs: 0,
|
|
152
160
|
};
|
|
153
161
|
|
|
154
162
|
let blockedUntil = 0;
|
|
@@ -260,6 +268,36 @@ function destroyBeforeReuse(ids) {
|
|
|
260
268
|
}
|
|
261
269
|
|
|
262
270
|
|
|
271
|
+
function getContentHeight() {
|
|
272
|
+
try {
|
|
273
|
+
const c = document.getElementById('content') || document.querySelector('main#panel') || document.body;
|
|
274
|
+
if (!c) return 0;
|
|
275
|
+
return Math.max(c.scrollHeight || 0, c.offsetHeight || 0);
|
|
276
|
+
} catch (_) { return 0; }
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function getShowSettleDelayMs(now = ts()) {
|
|
280
|
+
try {
|
|
281
|
+
if (S.pageWarmUntil && now < S.pageWarmUntil) return Math.max(0, Math.min(120, S.pageWarmUntil - now));
|
|
282
|
+
const h = getContentHeight();
|
|
283
|
+
const prevH = S.contentSampleH || 0;
|
|
284
|
+
const prevTs = S.contentSampleTs || 0;
|
|
285
|
+
S.contentSampleH = h;
|
|
286
|
+
S.contentSampleTs = now;
|
|
287
|
+
if (!prevTs || h <= 0) { S.settleDelaySince = 0; return 0; }
|
|
288
|
+
const grew = h - prevH;
|
|
289
|
+
const recent = (now - prevTs) <= CONTENT_SETTLE_WINDOW_MS;
|
|
290
|
+
if (recent && grew >= CONTENT_GROWTH_THRESHOLD_PX) {
|
|
291
|
+
if (!S.settleDelaySince) S.settleDelaySince = now;
|
|
292
|
+
if ((now - S.settleDelaySince) < CONTENT_SETTLE_MAX_DELAY_MS) return CONTENT_SETTLE_WINDOW_MS;
|
|
293
|
+
} else {
|
|
294
|
+
S.settleDelaySince = 0;
|
|
295
|
+
}
|
|
296
|
+
} catch (_) {}
|
|
297
|
+
return 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
|
|
263
301
|
// ── Config ─────────────────────────────────────────────────────────────────
|
|
264
302
|
|
|
265
303
|
async function fetchConfig() {
|
|
@@ -680,17 +718,19 @@ function enqueueShow(id) {
|
|
|
680
718
|
scheduleDrainQueue();
|
|
681
719
|
}
|
|
682
720
|
|
|
683
|
-
function scheduleDrainQueue() {
|
|
721
|
+
function scheduleDrainQueue(delayMs = BATCH_FLUSH_MS) {
|
|
684
722
|
if (isBlocked()) return;
|
|
685
723
|
if (S.showBatchTimer) return;
|
|
686
724
|
S.showBatchTimer = setTimeout(() => {
|
|
687
725
|
S.showBatchTimer = 0;
|
|
688
726
|
drainQueue();
|
|
689
|
-
},
|
|
727
|
+
}, Math.max(0, delayMs|0));
|
|
690
728
|
}
|
|
691
729
|
|
|
692
730
|
function drainQueue() {
|
|
693
731
|
if (isBlocked()) return;
|
|
732
|
+
const settleDelay = getShowSettleDelayMs();
|
|
733
|
+
if (settleDelay > 0) { scheduleDrainQueue(Math.max(BATCH_FLUSH_MS, settleDelay)); return; }
|
|
694
734
|
const free = Math.max(0, MAX_INFLIGHT - S.inflight);
|
|
695
735
|
if (!free || !S.pending.length) return;
|
|
696
736
|
|
|
@@ -908,6 +948,10 @@ function startShowBatch(ids) {
|
|
|
908
948
|
S.scrollSpeed = 0;
|
|
909
949
|
S.lastScrollY = 0;
|
|
910
950
|
S.lastScrollTs = 0;
|
|
951
|
+
S.pageWarmUntil = 0;
|
|
952
|
+
S.settleDelaySince = 0;
|
|
953
|
+
S.contentSampleH = 0;
|
|
954
|
+
S.contentSampleTs = 0;
|
|
911
955
|
}
|
|
912
956
|
|
|
913
957
|
// ── MutationObserver ───────────────────────────────────────────────────────
|
|
@@ -1013,6 +1057,10 @@ function startShowBatch(ids) {
|
|
|
1013
1057
|
S.pageKey = pageKey();
|
|
1014
1058
|
blockedUntil = 0;
|
|
1015
1059
|
muteConsole(); ensureTcfLocator(); warmNetwork();
|
|
1060
|
+
S.pageWarmUntil = ts() + PAGE_WARMUP_MS;
|
|
1061
|
+
S.settleDelaySince = 0;
|
|
1062
|
+
S.contentSampleH = getContentHeight();
|
|
1063
|
+
S.contentSampleTs = ts();
|
|
1016
1064
|
patchShowAds(); getIO(); ensureDomObserver(); sweepDeadWraps(); requestBurst();
|
|
1017
1065
|
});
|
|
1018
1066
|
|
|
@@ -1068,6 +1116,9 @@ function startShowBatch(ids) {
|
|
|
1068
1116
|
ensureDomObserver();
|
|
1069
1117
|
bindNodeBB();
|
|
1070
1118
|
bindScroll();
|
|
1119
|
+
S.pageWarmUntil = ts() + PAGE_WARMUP_MS;
|
|
1120
|
+
S.contentSampleH = getContentHeight();
|
|
1121
|
+
S.contentSampleTs = ts();
|
|
1071
1122
|
blockedUntil = 0;
|
|
1072
1123
|
requestBurst();
|
|
1073
1124
|
|