nodebb-plugin-ezoic-infinite 1.4.76 → 1.4.78

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 +44 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.4.76",
3
+ "version": "1.4.78",
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
@@ -283,16 +283,39 @@
283
283
  const orig = ez.showAds;
284
284
 
285
285
  ez.showAds = function (arg) {
286
+ // CRITIQUE: Filtrer IDs dont placeholders n'existent pas
287
+ const filterValidIds = (ids) => {
288
+ return ids.filter(id => {
289
+ const phId = `ezoic-pub-ad-placeholder-${id}`;
290
+ const ph = document.getElementById(phId);
291
+ return ph && ph.isConnected;
292
+ });
293
+ };
294
+
286
295
  if (Array.isArray(arg)) {
287
296
  const seen = new Set();
288
297
  for (const v of arg) {
289
298
  const id = parseInt(v, 10);
290
299
  if (!Number.isFinite(id) || id <= 0 || seen.has(id)) continue;
300
+
301
+ // Vérifier existence avant appel
302
+ const phId = `ezoic-pub-ad-placeholder-${id}`;
303
+ const ph = document.getElementById(phId);
304
+ if (!ph || !ph.isConnected) continue;
305
+
291
306
  seen.add(id);
292
307
  try { orig.call(ez, id); } catch (e) {}
293
308
  }
294
309
  return;
295
310
  }
311
+
312
+ // Pour appels simples, vérifier aussi
313
+ if (typeof arg === 'number') {
314
+ const phId = `ezoic-pub-ad-placeholder-${arg}`;
315
+ const ph = document.getElementById(phId);
316
+ if (!ph || !ph.isConnected) return;
317
+ }
318
+
296
319
  return orig.apply(ez, arguments);
297
320
  };
298
321
  } catch (e) {}
@@ -588,9 +611,28 @@
588
611
  }
589
612
 
590
613
  function cleanup() {
591
- destroyUsedPlaceholders();
614
+ // CRITIQUE: Détruire TOUS les placeholders Ezoic AVANT de supprimer DOM
615
+ // Pour annuler la queue interne d'Ezoic
616
+ const allWrappers = document.querySelectorAll('.ezoic-ad');
617
+ const allIds = [];
618
+ allWrappers.forEach(wrapper => {
619
+ const ph = wrapper.querySelector('[id^="ezoic-pub-ad-placeholder-"]');
620
+ if (ph) {
621
+ const match = ph.id.match(/\d+/);
622
+ if (match) allIds.push(parseInt(match[0]));
623
+ }
624
+ });
625
+
626
+ if (allIds.length > 0) {
627
+ destroyPlaceholderIds(allIds); // Dire à Ezoic d'arrêter
628
+ }
629
+
630
+ // Annuler batch showAds en attente
631
+ pendingShowAdsIds.clear();
632
+ clearTimeout(batchShowAdsTimer);
592
633
 
593
- document.querySelectorAll('.ezoic-ad').forEach(el => {
634
+ // Maintenant supprimer DOM
635
+ allWrappers.forEach(el => {
594
636
  try { el.remove(); } catch (e) {}
595
637
  });
596
638