nodebb-plugin-ezoic-infinite 1.0.11 → 1.0.13

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 +13 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Ezoic ads with infinite scroll using a pool of placeholder IDs",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/public/client.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  /* globals ajaxify */
4
4
  (function () {
5
+ try {
5
6
  if (window.ezoicInfiniteLoaded) return;
6
7
  window.ezoicInfiniteLoaded = true;
7
8
 
@@ -23,16 +24,20 @@
23
24
 
24
25
  function getPageKey() {
25
26
  try {
26
- if (ajaxify && ajaxify.data) {
27
- if (ajaxify.data.tid) return 'topic:' + ajaxify.data.tid;
28
- if (ajaxify.data.cid) return 'cid:' + ajaxify.data.cid + ':' + window.location.pathname;
27
+ const ax = window.ajaxify;
28
+ if (ax && ax.data) {
29
+ if (ax.data.tid) return 'topic:' + ax.data.tid;
30
+ if (ax.data.cid) return 'cid:' + ax.data.cid + ':' + window.location.pathname;
29
31
  }
30
32
  } catch (e) {}
31
33
  return window.location.pathname;
32
34
  }
33
35
 
34
36
  function isTopicPage() {
35
- try { return !!(ajaxify && ajaxify.data && ajaxify.data.tid); } catch (e) {}
37
+ try {
38
+ const ax = window.ajaxify;
39
+ return !!(ax && ax.data && ax.data.tid);
40
+ } catch (e) {}
36
41
  return /^\/topic\//.test(window.location.pathname);
37
42
  }
38
43
 
@@ -348,4 +353,8 @@ function bindNodeBBEvents() {
348
353
  setTimeout(run, 1200);
349
354
  });
350
355
  }
356
+ ;
357
+ } catch (e) {
358
+ // fail silently to avoid breaking NodeBB
359
+ }
351
360
  })();