nodebb-plugin-ezoic-infinite 1.7.7 → 1.7.9
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 +14 -49
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NodeBB Ezoic Infinite Ads — client.js v21
|
|
2
|
+
* NodeBB Ezoic Infinite Ads — client.js v21
|
|
3
3
|
*
|
|
4
4
|
* Historique des corrections majeures
|
|
5
5
|
* ────────────────────────────────────
|
|
@@ -96,7 +96,6 @@
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
let blockedUntil = 0;
|
|
99
|
-
let poolsReady = false; // true dès que les pools sont initialisés pour la page courante
|
|
100
99
|
const ts = () => Date.now();
|
|
101
100
|
const isBlocked = () => ts() < blockedUntil;
|
|
102
101
|
const isMobile = () => { try { return window.innerWidth < 768; } catch (_) { return false; } };
|
|
@@ -129,11 +128,9 @@
|
|
|
129
128
|
}
|
|
130
129
|
|
|
131
130
|
function initPools(cfg) {
|
|
132
|
-
if (poolsReady) return;
|
|
133
131
|
S.pools.topics = parseIds(cfg.placeholderIds);
|
|
134
132
|
S.pools.posts = parseIds(cfg.messagePlaceholderIds);
|
|
135
133
|
S.pools.categories = parseIds(cfg.categoryPlaceholderIds);
|
|
136
|
-
poolsReady = true;
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
// ── Page identity ──────────────────────────────────────────────────────────
|
|
@@ -182,9 +179,6 @@
|
|
|
182
179
|
|
|
183
180
|
// ── Ancres stables ─────────────────────────────────────────────────────────
|
|
184
181
|
|
|
185
|
-
// Map anchorKey → wrap Element — évite un querySelector full-DOM à chaque injection
|
|
186
|
-
const wrapByKey = new Map();
|
|
187
|
-
|
|
188
182
|
function stableId(klass, el) {
|
|
189
183
|
const attr = KIND[klass]?.anchorAttr;
|
|
190
184
|
if (attr) {
|
|
@@ -201,13 +195,13 @@
|
|
|
201
195
|
|
|
202
196
|
const anchorKey = (klass, el) => `${klass}:${stableId(klass, el)}`;
|
|
203
197
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
198
|
+
function findWrap(key) {
|
|
199
|
+
try {
|
|
200
|
+
return document.querySelector(
|
|
201
|
+
`.${WRAP_CLASS}[${A_ANCHOR}="${key.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"]`
|
|
202
|
+
);
|
|
203
|
+
} catch (_) { return null; }
|
|
204
|
+
}
|
|
211
205
|
|
|
212
206
|
// ── Pool ───────────────────────────────────────────────────────────────────
|
|
213
207
|
|
|
@@ -246,20 +240,17 @@
|
|
|
246
240
|
const w = makeWrap(id, klass, key);
|
|
247
241
|
mutate(() => el.insertAdjacentElement('afterend', w));
|
|
248
242
|
S.mountedIds.add(id);
|
|
249
|
-
wrapByKey.set(key, w);
|
|
250
243
|
return w;
|
|
251
244
|
}
|
|
252
245
|
|
|
253
246
|
function dropWrap(w) {
|
|
254
247
|
try {
|
|
255
|
-
// Unobserve
|
|
256
|
-
//
|
|
248
|
+
// Unobserve avant remove — guard instanceof évite unobserve(null)
|
|
249
|
+
// qui corrompt l'état interne de l'IO (pubads error au scroll suivant)
|
|
257
250
|
const ph = w.querySelector(`[id^="${PH_PREFIX}"]`);
|
|
258
|
-
if (ph instanceof Element
|
|
251
|
+
if (ph instanceof Element) S.io?.unobserve(ph);
|
|
259
252
|
const id = parseInt(w.getAttribute(A_WRAPID), 10);
|
|
260
253
|
if (Number.isFinite(id)) S.mountedIds.delete(id);
|
|
261
|
-
const key = w.getAttribute(A_ANCHOR);
|
|
262
|
-
if (key) wrapByKey.delete(key);
|
|
263
254
|
w.remove();
|
|
264
255
|
} catch (_) {}
|
|
265
256
|
}
|
|
@@ -387,7 +378,7 @@
|
|
|
387
378
|
|
|
388
379
|
function observePh(id) {
|
|
389
380
|
const ph = document.getElementById(`${PH_PREFIX}${id}`);
|
|
390
|
-
if (ph
|
|
381
|
+
if (ph?.isConnected) try { getIO()?.observe(ph); } catch (_) {}
|
|
391
382
|
}
|
|
392
383
|
|
|
393
384
|
function enqueueShow(id) {
|
|
@@ -492,6 +483,7 @@
|
|
|
492
483
|
|
|
493
484
|
async function runCore() {
|
|
494
485
|
if (isBlocked()) return 0;
|
|
486
|
+
patchShowAds();
|
|
495
487
|
|
|
496
488
|
const cfg = await fetchConfig();
|
|
497
489
|
if (!cfg || cfg.excluded) return 0;
|
|
@@ -566,32 +558,7 @@
|
|
|
566
558
|
|
|
567
559
|
function cleanup() {
|
|
568
560
|
blockedUntil = ts() + 1500;
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
// Unobserve ciblé sur NOS placeholders avant de les retirer du DOM.
|
|
572
|
-
// On ne fait JAMAIS disconnect() — c'est un IO global partagé avec pubads ;
|
|
573
|
-
// disconnect() corrompt son état interne et provoque des erreurs sur tous
|
|
574
|
-
// les observe() suivants de Google ("parameter 1 is not of type 'Element'").
|
|
575
|
-
if (S.io) {
|
|
576
|
-
for (const id of S.mountedIds) {
|
|
577
|
-
try {
|
|
578
|
-
const ph = document.getElementById(`${PH_PREFIX}${id}`);
|
|
579
|
-
if (ph instanceof Element && ph.isConnected) S.io.unobserve(ph);
|
|
580
|
-
} catch (_) {}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
mutate(() => document.querySelectorAll(`.${WRAP_CLASS}`).forEach(w => {
|
|
585
|
-
try {
|
|
586
|
-
const id = parseInt(w.getAttribute(A_WRAPID), 10);
|
|
587
|
-
if (Number.isFinite(id)) S.mountedIds.delete(id);
|
|
588
|
-
const key = w.getAttribute(A_ANCHOR);
|
|
589
|
-
if (key) wrapByKey.delete(key);
|
|
590
|
-
w.remove();
|
|
591
|
-
} catch (_) {}
|
|
592
|
-
}));
|
|
593
|
-
|
|
594
|
-
wrapByKey.clear();
|
|
561
|
+
mutate(() => document.querySelectorAll(`.${WRAP_CLASS}`).forEach(dropWrap));
|
|
595
562
|
S.cfg = null;
|
|
596
563
|
S.pools = { topics: [], posts: [], categories: [] };
|
|
597
564
|
S.cursors = { topics: 0, posts: 0, categories: 0 };
|
|
@@ -610,8 +577,6 @@
|
|
|
610
577
|
if (S.domObs) return;
|
|
611
578
|
const allSel = [SEL.post, SEL.topic, SEL.category];
|
|
612
579
|
S.domObs = new MutationObserver(muts => {
|
|
613
|
-
// Ne rien faire pendant la navigation (cleanup posé blockedUntil)
|
|
614
|
-
// ou si c'est nous qui mutons le DOM.
|
|
615
580
|
if (S.mutGuard > 0 || isBlocked()) return;
|
|
616
581
|
for (const m of muts) {
|
|
617
582
|
for (const n of m.addedNodes) {
|