nodebb-plugin-ezoic-infinite 1.7.26 → 1.7.27
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 +19 -20
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NodeBB Ezoic Infinite Ads — client.js
|
|
2
|
+
* NodeBB Ezoic Infinite Ads — client.js v33
|
|
3
3
|
*
|
|
4
4
|
* Historique des corrections majeures
|
|
5
5
|
* ────────────────────────────────────
|
|
@@ -262,31 +262,30 @@
|
|
|
262
262
|
return null;
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
function
|
|
266
|
-
// Quand le pool est épuisé :
|
|
267
|
-
//
|
|
265
|
+
function recycleDistantWrap(klass) {
|
|
266
|
+
// Quand le pool est épuisé : récupère le wrap le plus loin au-dessus du
|
|
267
|
+
// viewport (qu'il soit orphelin ou non) pour libérer son ID.
|
|
268
|
+
// Les topics/pubs à 4+ viewports au-dessus ne sont plus visibles — on peut
|
|
269
|
+
// recycler leur slot. Non-remplis en priorité, remplis si rien d'autre.
|
|
268
270
|
const vh = window.innerHeight || 800;
|
|
269
|
-
const threshold = -vh *
|
|
270
|
-
|
|
271
|
+
const threshold = -vh * 4;
|
|
272
|
+
|
|
273
|
+
let bestEmpty = null, bestEmptyBottom = Infinity;
|
|
274
|
+
let bestFilled = null, bestFilledBottom = Infinity;
|
|
275
|
+
|
|
271
276
|
document.querySelectorAll(`.${WRAP_CLASS}.${klass}`).forEach(wrap => {
|
|
272
|
-
if (wrap.getAttribute(A_CREATED) === null) return;
|
|
273
|
-
if (isFilled(wrap)) return;
|
|
274
|
-
const key = wrap.getAttribute(A_ANCHOR);
|
|
275
|
-
if (!key) return;
|
|
276
|
-
const colonIdx = key.indexOf(':');
|
|
277
|
-
const anchorId = key.slice(colonIdx + 1);
|
|
278
|
-
const cfg = KIND[klass];
|
|
279
|
-
if (!cfg) return;
|
|
280
|
-
try {
|
|
281
|
-
const found = document.querySelector(`${cfg.sel}[${cfg.anchorAttr}="${anchorId}"]`);
|
|
282
|
-
if (found?.isConnected) return; // ancre encore dans le DOM, pas orphelin
|
|
283
|
-
} catch (_) { return; }
|
|
284
277
|
try {
|
|
285
278
|
const rect = wrap.getBoundingClientRect();
|
|
286
279
|
if (rect.bottom > threshold) return;
|
|
287
|
-
if (
|
|
280
|
+
if (!isFilled(wrap)) {
|
|
281
|
+
if (rect.bottom < bestEmptyBottom) { bestEmptyBottom = rect.bottom; bestEmpty = wrap; }
|
|
282
|
+
} else {
|
|
283
|
+
if (rect.bottom < bestFilledBottom) { bestFilledBottom = rect.bottom; bestFilled = wrap; }
|
|
284
|
+
}
|
|
288
285
|
} catch (_) {}
|
|
289
286
|
});
|
|
287
|
+
|
|
288
|
+
const best = bestEmpty ?? bestFilled;
|
|
290
289
|
if (!best) return null;
|
|
291
290
|
const id = parseInt(best.getAttribute(A_WRAPID), 10);
|
|
292
291
|
if (!Number.isFinite(id)) return null;
|
|
@@ -410,7 +409,7 @@
|
|
|
410
409
|
if (findWrap(key)) continue;
|
|
411
410
|
|
|
412
411
|
let id = pickId(poolKey);
|
|
413
|
-
if (!id) { id =
|
|
412
|
+
if (!id) { id = recycleDistantWrap(klass); if (!id) continue; }
|
|
414
413
|
|
|
415
414
|
const w = insertAfter(el, id, klass, key);
|
|
416
415
|
if (w) { observePh(id); inserted++; }
|