nodebb-plugin-ezoic-infinite 1.2.5 → 1.2.6

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 +34 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
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
@@ -367,7 +367,40 @@
367
367
  return inserted;
368
368
  }
369
369
 
370
+
371
+ function destroyUsedPlaceholders() {
372
+ const ids = [];
373
+ try {
374
+ state.usedTopics.forEach((id) => ids.push(id));
375
+ state.usedPosts.forEach((id) => ids.push(id));
376
+ } catch (e) {}
377
+
378
+ if (!ids.length) return;
379
+
380
+ const call = () => {
381
+ try {
382
+ if (window.ezstandalone && typeof window.ezstandalone.destroyPlaceholders === 'function') {
383
+ window.ezstandalone.destroyPlaceholders(ids);
384
+ }
385
+ } catch (e) {}
386
+ };
387
+
388
+ try {
389
+ window.ezstandalone = window.ezstandalone || {};
390
+ window.ezstandalone.cmd = window.ezstandalone.cmd || [];
391
+
392
+ if (window.ezstandalone && typeof window.ezstandalone.destroyPlaceholders === 'function') {
393
+ call();
394
+ } else {
395
+ // queue for when ezstandalone becomes ready
396
+ window.ezstandalone.cmd.push(call);
397
+ }
398
+ } catch (e) {}
399
+ }
400
+
370
401
  function cleanup() {
402
+ // Destroy slots for IDs we used on the previous view before we reuse the same IDs on the next page
403
+ destroyUsedPlaceholders();
371
404
  state.pageKey = getPageKey();
372
405
  state.cfg = null;
373
406
  state.cfgPromise = null;
@@ -400,6 +433,7 @@
400
433
 
401
434
  async function runCore() {
402
435
  patchShowAds();
436
+ patchShowAds();
403
437
 
404
438
  const cfg = await fetchConfig();
405
439
  if (!cfg || cfg.excluded) return;