nodebb-plugin-ezoic-infinite 1.5.25 → 1.5.26

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 +18 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.5.25",
3
+ "version": "1.5.26",
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
@@ -37,6 +37,9 @@
37
37
  // throttle per placeholder id
38
38
  lastShowById: new Map(),
39
39
 
40
+ // track placeholders that have been shown at least once in this pageview
41
+ usedOnce: new Set(),
42
+
40
43
  // observers / schedulers
41
44
  domObs: null,
42
45
  io: null,
@@ -330,7 +333,13 @@
330
333
 
331
334
  // Fast path
332
335
  if (typeof ez.showAds === 'function') {
336
+ try {
337
+ if (state.usedOnce && state.usedOnce.has(id) && typeof ez.destroyPlaceholders === 'function') {
338
+ ez.destroyPlaceholders(id);
339
+ }
340
+ } catch (e) {}
333
341
  ez.showAds(id);
342
+ try { state.usedOnce && state.usedOnce.add(id); } catch (e) {}
334
343
  return;
335
344
  }
336
345
 
@@ -343,7 +352,14 @@
343
352
  if (EZOIC_BLOCKED) return;
344
353
  const el = document.getElementById(`${PLACEHOLDER_PREFIX}${id}`);
345
354
  if (!el || !el.isConnected) return;
346
- window.ezstandalone.showAds(id);
355
+ const ez2 = window.ezstandalone;
356
+ try {
357
+ if (state.usedOnce && state.usedOnce.has(id) && typeof ez2.destroyPlaceholders === 'function') {
358
+ ez2.destroyPlaceholders(id);
359
+ }
360
+ } catch (e) {}
361
+ ez2.showAds(id);
362
+ try { state.usedOnce && state.usedOnce.add(id); } catch (e) {}
347
363
  } catch (e) {}
348
364
  });
349
365
  }
@@ -570,6 +586,7 @@
570
586
  state.curPosts = 0;
571
587
  state.curCategories = 0;
572
588
  state.lastShowById.clear();
589
+ try { state.usedOnce && state.usedOnce.clear(); } catch (e) {}
573
590
  state.heroDoneForPage = false;
574
591
 
575
592
  // keep observers alive (MutationObserver will re-trigger after navigation)