nodebb-plugin-ezoic-infinite 0.7.4 → 0.7.5

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 +8 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
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
@@ -61,8 +61,7 @@ function isTopicPage() {
61
61
  try {
62
62
  if (ajaxify && ajaxify.data && ajaxify.data.tid) return true;
63
63
  } catch (e) {}
64
- if (/^\/topic\//.test(window.location.pathname)) return true;
65
- return $('[component="post/content"]').length > 0;
64
+ return /^\/topic\//.test(window.location.pathname);
66
65
  }
67
66
 
68
67
  function isCategoryTopicListPage() {
@@ -342,9 +341,10 @@ async function refreshAds() {
342
341
  const messagePool = parsePool(cfg.messagePlaceholderIds);
343
342
  const messageInterval = Math.max(1, parseInt(cfg.messageIntervalPosts, 10) || 3);
344
343
 
345
- const onTopic = isTopicPage();
346
344
  const hasTopicList = isCategoryTopicListPage();
347
- const onCategory = !onTopic && hasTopicList;
345
+ const onTopic = isTopicPage();
346
+ // If a topic-list is present, we are on a category-like page even if other post-like widgets exist.
347
+ const onCategory = hasTopicList && !onTopic;
348
348
 
349
349
  const newIds = [];
350
350
 
@@ -393,11 +393,15 @@ setTimeout(function(){ setupAdAutoHeight(); debounceRefresh(); }, 2200);
393
393
  for (const n of m.addedNodes) {
394
394
  if (!n || n.nodeType !== 1) continue;
395
395
  // direct match
396
+ const inContent = (n.closest && n.closest('#content')) || (n.querySelector && n.querySelector('#content'));
397
+ if (!inContent && !document.querySelector('#content')) { /* if #content missing, proceed */ }
398
+ if (document.querySelector('#content') && !(n.closest && n.closest('#content'))) { continue; }
396
399
  if (n.matches && (n.matches('[component="post"][data-pid]') || n.matches('li[component="category/topic"]'))) {
397
400
  debounceRefresh();
398
401
  return;
399
402
  }
400
403
  // descendant match
404
+ if (document.querySelector('#content') && !(n.closest && n.closest('#content'))) { continue; }
401
405
  if (n.querySelector && (n.querySelector('[component="post"][data-pid]') || n.querySelector('li[component="category/topic"]'))) {
402
406
  debounceRefresh();
403
407
  return;