nodebb-plugin-ezoic-infinite 1.7.8 → 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 +11 -24
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,21 +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
|
-
//
|
|
257
|
-
// (même logique que v20.3 qui fonctionnait).
|
|
248
|
+
// Unobserve avant remove — guard instanceof évite unobserve(null)
|
|
249
|
+
// qui corrompt l'état interne de l'IO (pubads error au scroll suivant)
|
|
258
250
|
const ph = w.querySelector(`[id^="${PH_PREFIX}"]`);
|
|
259
251
|
if (ph instanceof Element) S.io?.unobserve(ph);
|
|
260
252
|
const id = parseInt(w.getAttribute(A_WRAPID), 10);
|
|
261
253
|
if (Number.isFinite(id)) S.mountedIds.delete(id);
|
|
262
|
-
const key = w.getAttribute(A_ANCHOR);
|
|
263
|
-
if (key) wrapByKey.delete(key);
|
|
264
254
|
w.remove();
|
|
265
255
|
} catch (_) {}
|
|
266
256
|
}
|
|
@@ -493,6 +483,7 @@
|
|
|
493
483
|
|
|
494
484
|
async function runCore() {
|
|
495
485
|
if (isBlocked()) return 0;
|
|
486
|
+
patchShowAds();
|
|
496
487
|
|
|
497
488
|
const cfg = await fetchConfig();
|
|
498
489
|
if (!cfg || cfg.excluded) return 0;
|
|
@@ -567,9 +558,7 @@
|
|
|
567
558
|
|
|
568
559
|
function cleanup() {
|
|
569
560
|
blockedUntil = ts() + 1500;
|
|
570
|
-
poolsReady = false;
|
|
571
561
|
mutate(() => document.querySelectorAll(`.${WRAP_CLASS}`).forEach(dropWrap));
|
|
572
|
-
wrapByKey.clear();
|
|
573
562
|
S.cfg = null;
|
|
574
563
|
S.pools = { topics: [], posts: [], categories: [] };
|
|
575
564
|
S.cursors = { topics: 0, posts: 0, categories: 0 };
|
|
@@ -588,8 +577,6 @@
|
|
|
588
577
|
if (S.domObs) return;
|
|
589
578
|
const allSel = [SEL.post, SEL.topic, SEL.category];
|
|
590
579
|
S.domObs = new MutationObserver(muts => {
|
|
591
|
-
// Ne rien faire pendant la navigation (cleanup posé blockedUntil)
|
|
592
|
-
// ou si c'est nous qui mutons le DOM.
|
|
593
580
|
if (S.mutGuard > 0 || isBlocked()) return;
|
|
594
581
|
for (const m of muts) {
|
|
595
582
|
for (const n of m.addedNodes) {
|