nodebb-plugin-ezoic-infinite 1.7.6 → 1.7.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/client.js +27 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/public/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * NodeBB Ezoic Infinite Ads — client.js v21.2
2
+ * NodeBB Ezoic Infinite Ads — client.js v21.3
3
3
  *
4
4
  * Historique des corrections majeures
5
5
  * ────────────────────────────────────
@@ -252,10 +252,8 @@
252
252
 
253
253
  function dropWrap(w) {
254
254
  try {
255
- // Unobserve seulement si le placeholder est encore dans le DOM.
256
- // unobserve() sur un nœud détaché corrompt l'IO interne de pubads
257
- // → "Failed to execute 'observe': parameter 1 is not of type 'Element'"
258
- // sur tous les observe() suivants.
255
+ // Unobserve uniquement si le ph est encore connecté un nœud détaché
256
+ // passé à unobserve() corrompt l'IO interne de pubads.
259
257
  const ph = w.querySelector(`[id^="${PH_PREFIX}"]`);
260
258
  if (ph instanceof Element && ph.isConnected) S.io?.unobserve(ph);
261
259
  const id = parseInt(w.getAttribute(A_WRAPID), 10);
@@ -570,14 +568,29 @@
570
568
  blockedUntil = ts() + 1500;
571
569
  poolsReady = false;
572
570
 
573
- // Déconnecter l'IO AVANT les dropWrap pour éviter tout unobserve parasite.
574
- // disconnect() vide la liste interne des cibles observées les références
575
- // aux placeholders de la page courante sont effacées proprement.
576
- // L'IO sera recréé à ajaxify.end via getIO().
577
- try { S.io?.disconnect(); } catch (_) {}
578
- S.io = null;
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
+ }));
579
593
 
580
- mutate(() => document.querySelectorAll(`.${WRAP_CLASS}`).forEach(dropWrap));
581
594
  wrapByKey.clear();
582
595
  S.cfg = null;
583
596
  S.pools = { topics: [], posts: [], categories: [] };
@@ -597,6 +610,8 @@
597
610
  if (S.domObs) return;
598
611
  const allSel = [SEL.post, SEL.topic, SEL.category];
599
612
  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.
600
615
  if (S.mutGuard > 0 || isBlocked()) return;
601
616
  for (const m of muts) {
602
617
  for (const n of m.addedNodes) {