nodebb-plugin-ezoic-infinite 0.7.4 → 0.7.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.
- package/package.json +1 -1
- package/public/client.js +10 -9
package/package.json
CHANGED
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
|
-
|
|
65
|
-
return $('[component="post/content"]').length > 0;
|
|
64
|
+
return /^\/topic\//.test(window.location.pathname);
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
function isCategoryTopicListPage() {
|
|
@@ -194,11 +193,8 @@ function callEzoic(ids) {
|
|
|
194
193
|
window.ezstandalone.cmd = window.ezstandalone.cmd || [];
|
|
195
194
|
|
|
196
195
|
const run = function () {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
window.ezstandalone.destroyPlaceholders.apply(window.ezstandalone, ids);
|
|
200
|
-
}
|
|
201
|
-
} catch (e) {}
|
|
196
|
+
// destroyPlaceholders is only needed when placeholder IDs are reused.
|
|
197
|
+
// This plugin avoids reusing IDs on the same page, so we skip it to prevent Ezoic from removing valid placeholders.
|
|
202
198
|
try {
|
|
203
199
|
if (typeof window.ezstandalone.showAds === 'function') {
|
|
204
200
|
window.ezstandalone.showAds.apply(window.ezstandalone, ids);
|
|
@@ -342,9 +338,10 @@ async function refreshAds() {
|
|
|
342
338
|
const messagePool = parsePool(cfg.messagePlaceholderIds);
|
|
343
339
|
const messageInterval = Math.max(1, parseInt(cfg.messageIntervalPosts, 10) || 3);
|
|
344
340
|
|
|
345
|
-
const onTopic = isTopicPage();
|
|
346
341
|
const hasTopicList = isCategoryTopicListPage();
|
|
347
|
-
const
|
|
342
|
+
const onTopic = isTopicPage();
|
|
343
|
+
// If a topic-list is present, we are on a category-like page even if other post-like widgets exist.
|
|
344
|
+
const onCategory = hasTopicList && !onTopic;
|
|
348
345
|
|
|
349
346
|
const newIds = [];
|
|
350
347
|
|
|
@@ -393,11 +390,15 @@ setTimeout(function(){ setupAdAutoHeight(); debounceRefresh(); }, 2200);
|
|
|
393
390
|
for (const n of m.addedNodes) {
|
|
394
391
|
if (!n || n.nodeType !== 1) continue;
|
|
395
392
|
// direct match
|
|
393
|
+
const inContent = (n.closest && n.closest('#content')) || (n.querySelector && n.querySelector('#content'));
|
|
394
|
+
if (!inContent && !document.querySelector('#content')) { /* if #content missing, proceed */ }
|
|
395
|
+
if (document.querySelector('#content') && !(n.closest && n.closest('#content'))) { continue; }
|
|
396
396
|
if (n.matches && (n.matches('[component="post"][data-pid]') || n.matches('li[component="category/topic"]'))) {
|
|
397
397
|
debounceRefresh();
|
|
398
398
|
return;
|
|
399
399
|
}
|
|
400
400
|
// descendant match
|
|
401
|
+
if (document.querySelector('#content') && !(n.closest && n.closest('#content'))) { continue; }
|
|
401
402
|
if (n.querySelector && (n.querySelector('[component="post"][data-pid]') || n.querySelector('li[component="category/topic"]'))) {
|
|
402
403
|
debounceRefresh();
|
|
403
404
|
return;
|