nodebb-plugin-ezoic-infinite 0.7.3 → 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.
- package/package.json +1 -1
- package/public/client.js +33 -5
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -58,7 +58,10 @@ async function fetchConfig() {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
function isTopicPage() {
|
|
61
|
-
|
|
61
|
+
try {
|
|
62
|
+
if (ajaxify && ajaxify.data && ajaxify.data.tid) return true;
|
|
63
|
+
} catch (e) {}
|
|
64
|
+
return /^\/topic\//.test(window.location.pathname);
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
function isCategoryTopicListPage() {
|
|
@@ -178,6 +181,12 @@ function setupAdAutoHeight() {
|
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
function callEzoic(ids) {
|
|
184
|
+
const key = Array.isArray(ids) ? ids.join(',') : String(ids);
|
|
185
|
+
if (window.__ezoicLastShowKey === key && Date.now() - (window.__ezoicLastShowAt || 0) < 2000) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
window.__ezoicLastShowKey = key;
|
|
189
|
+
window.__ezoicLastShowAt = Date.now();
|
|
181
190
|
if (!ids || !ids.length) return;
|
|
182
191
|
|
|
183
192
|
window.ezstandalone = window.ezstandalone || {};
|
|
@@ -201,12 +210,25 @@ function callEzoic(ids) {
|
|
|
201
210
|
setupAdAutoHeight();
|
|
202
211
|
window.ezstandalone.cmd.push(function () { run(); });
|
|
203
212
|
|
|
213
|
+
// Retry only if showAds isn't available yet (avoid duplicate calls)
|
|
204
214
|
let tries = 0;
|
|
205
215
|
const maxTries = 6;
|
|
206
|
-
const
|
|
216
|
+
const retry = function () {
|
|
207
217
|
tries++;
|
|
208
|
-
|
|
209
|
-
|
|
218
|
+
const ok = run();
|
|
219
|
+
if (ok) return;
|
|
220
|
+
try {
|
|
221
|
+
if (typeof window.ezstandalone.showAds === 'function') return;
|
|
222
|
+
} catch (e) {}
|
|
223
|
+
if (tries < maxTries) setTimeout(retry, 800);
|
|
224
|
+
};
|
|
225
|
+
try {
|
|
226
|
+
if (typeof window.ezstandalone.showAds !== 'function') {
|
|
227
|
+
setTimeout(retry, 800);
|
|
228
|
+
}
|
|
229
|
+
} catch (e) {
|
|
230
|
+
setTimeout(retry, 800);
|
|
231
|
+
}
|
|
210
232
|
}
|
|
211
233
|
|
|
212
234
|
function getPostNumber($post) {
|
|
@@ -319,8 +341,10 @@ async function refreshAds() {
|
|
|
319
341
|
const messagePool = parsePool(cfg.messagePlaceholderIds);
|
|
320
342
|
const messageInterval = Math.max(1, parseInt(cfg.messageIntervalPosts, 10) || 3);
|
|
321
343
|
|
|
344
|
+
const hasTopicList = isCategoryTopicListPage();
|
|
322
345
|
const onTopic = isTopicPage();
|
|
323
|
-
|
|
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;
|
|
324
348
|
|
|
325
349
|
const newIds = [];
|
|
326
350
|
|
|
@@ -369,11 +393,15 @@ setTimeout(function(){ setupAdAutoHeight(); debounceRefresh(); }, 2200);
|
|
|
369
393
|
for (const n of m.addedNodes) {
|
|
370
394
|
if (!n || n.nodeType !== 1) continue;
|
|
371
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; }
|
|
372
399
|
if (n.matches && (n.matches('[component="post"][data-pid]') || n.matches('li[component="category/topic"]'))) {
|
|
373
400
|
debounceRefresh();
|
|
374
401
|
return;
|
|
375
402
|
}
|
|
376
403
|
// descendant match
|
|
404
|
+
if (document.querySelector('#content') && !(n.closest && n.closest('#content'))) { continue; }
|
|
377
405
|
if (n.querySelector && (n.querySelector('[component="post"][data-pid]') || n.querySelector('li[component="category/topic"]'))) {
|
|
378
406
|
debounceRefresh();
|
|
379
407
|
return;
|