nodebb-plugin-ezoic-infinite 1.8.99 → 1.9.0

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.
package/library.js CHANGED
@@ -243,6 +243,8 @@ plugin.injectEzoicHead = async (data) => {
243
243
  };
244
244
 
245
245
  plugin.init = async ({ router, middleware }) => {
246
+ getSettings().catch(() => {});
247
+
246
248
  async function render(req, res) {
247
249
  const settings = await getSettings();
248
250
  const allGroups = await getAllGroups();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.8.99",
3
+ "version": "1.9.0",
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
@@ -101,6 +101,7 @@
101
101
  burstDeadline: 0,
102
102
  burstCount: 0,
103
103
  lastBurstTs: 0,
104
+ cleaningUp: false,
104
105
  };
105
106
 
106
107
  const isBlocked = () => now() < S.blockedUntil;
@@ -121,10 +122,8 @@
121
122
 
122
123
  async function fetchConfig() {
123
124
  if (S.cfg) return S.cfg;
124
- try {
125
- const inline = window.__nbbEzoicCfg;
126
- if (inline && typeof inline === 'object') { S.cfg = inline; return S.cfg; }
127
- } catch (_) {}
125
+ const inline = window.__nbbEzoicCfg;
126
+ if (inline && typeof inline === 'object') { S.cfg = inline; return S.cfg; }
128
127
  try {
129
128
  const ctrl = new AbortController();
130
129
  const t = setTimeout(() => ctrl.abort(), 5_000);
@@ -205,14 +204,14 @@
205
204
  function getTopics() {
206
205
  const t = now();
207
206
  if (_topicsCache && t - _topicsCacheTs < POSTS_CACHE_MS) return _topicsCache;
208
- _topicsCache = document.querySelectorAll(SEL.topic);
207
+ _topicsCache = Array.from(document.querySelectorAll(SEL.topic));
209
208
  _topicsCacheTs = t;
210
209
  return _topicsCache;
211
210
  }
212
211
  function getCategories() {
213
212
  const t = now();
214
213
  if (_catsCache && t - _catsCacheTs < POSTS_CACHE_MS) return _catsCache;
215
- _catsCache = document.querySelectorAll(SEL.category);
214
+ _catsCache = Array.from(document.querySelectorAll(SEL.category));
216
215
  _catsCacheTs = t;
217
216
  return _catsCache;
218
217
  }
@@ -435,15 +434,19 @@
435
434
  if (ph instanceof Element) S.io?.unobserve(ph);
436
435
  const id = parseInt(w.getAttribute(ATTR.WRAPID), 10);
437
436
  if (Number.isFinite(id)) {
438
- S.mountedIds.delete(id);
439
- S.lastShow.delete(id);
440
437
  const timers = S.wrapTimers.get(id);
441
438
  if (timers) { for (const t of timers) clearTimeout(t); S.wrapTimers.delete(id); }
439
+ if (!S.cleaningUp) {
440
+ S.mountedIds.delete(id);
441
+ S.lastShow.delete(id);
442
+ }
443
+ }
444
+ if (!S.cleaningUp) {
445
+ const key = w.getAttribute(ATTR.ANCHOR);
446
+ if (key && S.wrapByKey.get(key) === w) S.wrapByKey.delete(key);
447
+ const colonIdx = key?.indexOf(':') ?? -1;
448
+ if (colonIdx > 0) S.wrapsByClass.get(key.slice(0, colonIdx))?.delete(w);
442
449
  }
443
- const key = w.getAttribute(ATTR.ANCHOR);
444
- if (key && S.wrapByKey.get(key) === w) S.wrapByKey.delete(key);
445
- const colonIdx = key?.indexOf(':') ?? -1;
446
- if (colonIdx > 0) S.wrapsByClass.get(key.slice(0, colonIdx))?.delete(w);
447
450
  w.remove();
448
451
  } catch (_) {}
449
452
  }
@@ -722,9 +725,12 @@
722
725
  const ez = window.ezstandalone;
723
726
  if (typeof ez?.destroyPlaceholders === 'function') ez.destroyPlaceholders();
724
727
  } catch (_) {}
728
+ S.cleaningUp = true;
725
729
  mutate(() => {
726
730
  for (const w of document.querySelectorAll(`.${WRAP_CLASS}`)) dropWrap(w);
727
731
  });
732
+ S.cleaningUp = false;
733
+ // Safety net: wrapTimers should be empty after dropWrap loop, but clear any orphans.
728
734
  for (const timers of S.wrapTimers.values()) { for (const t of timers) clearTimeout(t); }
729
735
  S.wrapTimers.clear();
730
736
  S.domObs?.disconnect(); S.domObs = null;