nodebb-plugin-ezoic-infinite 1.4.75 → 1.4.77

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 +46 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.4.75",
3
+ "version": "1.4.77",
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
@@ -142,10 +142,15 @@
142
142
  const ph = wrapper.querySelector('[id^="ezoic-pub-ad-placeholder-"]');
143
143
  if (!ph) return;
144
144
 
145
- // ULTRA-AGRESSIF: Supprimer TOUT sauf le placeholder
145
+ // SÉCURISÉ: Supprimer TOUT sauf le placeholder
146
+ // CRITIQUE: Ne JAMAIS toucher au placeholder ou ses enfants
146
147
  Array.from(wrapper.children).forEach(child => {
147
- if (child === ph || child.contains(ph)) return;
148
- // Supprimer TOUT le reste
148
+ // Vérifier que ce n'est PAS le placeholder
149
+ if (child === ph) return;
150
+ if (child.contains(ph)) return;
151
+ if (child.id && child.id.startsWith('ezoic-pub-ad-placeholder-')) return;
152
+
153
+ // Supprimer le reste
149
154
  child.remove();
150
155
  });
151
156
 
@@ -278,16 +283,39 @@
278
283
  const orig = ez.showAds;
279
284
 
280
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
+
281
295
  if (Array.isArray(arg)) {
282
296
  const seen = new Set();
283
297
  for (const v of arg) {
284
298
  const id = parseInt(v, 10);
285
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
+
286
306
  seen.add(id);
287
307
  try { orig.call(ez, id); } catch (e) {}
288
308
  }
289
309
  return;
290
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
+
291
319
  return orig.apply(ez, arguments);
292
320
  };
293
321
  } catch (e) {}
@@ -379,6 +407,14 @@
379
407
  const idsArray = Array.from(pendingShowAdsIds);
380
408
  pendingShowAdsIds.clear();
381
409
 
410
+ // CRITIQUE: Vérifier que placeholders existent encore
411
+ const validIds = idsArray.filter(id => {
412
+ const ph = document.getElementById(`${PLACEHOLDER_PREFIX}${id}`);
413
+ return ph && ph.isConnected;
414
+ });
415
+
416
+ if (validIds.length === 0) return;
417
+
382
418
  // Appeler showAds avec TOUS les IDs en une fois
383
419
  try {
384
420
  window.ezstandalone = window.ezstandalone || {};
@@ -386,9 +422,9 @@
386
422
  window.ezstandalone.cmd.push(function() {
387
423
  if (typeof window.ezstandalone.showAds === 'function') {
388
424
  // Appel batch: showAds(id1, id2, id3...)
389
- window.ezstandalone.showAds(...idsArray);
425
+ window.ezstandalone.showAds(...validIds);
390
426
  // Tracker tous les IDs
391
- idsArray.forEach(id => {
427
+ validIds.forEach(id => {
392
428
  state.lastShowById.set(id, Date.now());
393
429
  sessionDefinedIds.add(id);
394
430
  });
@@ -399,7 +435,7 @@
399
435
  // CRITIQUE: Nettoyer éléments invisibles APRÈS que pubs soient chargées
400
436
  setTimeout(() => {
401
437
  cleanupInvisibleEzoicElements();
402
- }, 800); // 1.5s pour laisser Ezoic charger
438
+ }, 1500); // 1.5s pour laisser Ezoic charger
403
439
  }, 100);
404
440
  }
405
441
 
@@ -577,6 +613,10 @@
577
613
  function cleanup() {
578
614
  destroyUsedPlaceholders();
579
615
 
616
+ // CRITIQUE: Annuler batch showAds en attente pour éviter erreurs console
617
+ pendingShowAdsIds.clear();
618
+ clearTimeout(batchShowAdsTimer);
619
+
580
620
  document.querySelectorAll('.ezoic-ad').forEach(el => {
581
621
  try { el.remove(); } catch (e) {}
582
622
  });