nodebb-plugin-ezoic-infinite 1.4.57 → 1.4.59
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 +2 -2
- package/public/client.js +22 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-ezoic-infinite",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.59",
|
|
4
4
|
"description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
|
|
5
5
|
"main": "library.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
"compatibility": "^4.0.0"
|
|
19
19
|
},
|
|
20
20
|
"private": false
|
|
21
|
-
}
|
|
21
|
+
}
|
package/public/client.js
CHANGED
|
@@ -63,7 +63,10 @@
|
|
|
63
63
|
|
|
64
64
|
// Retry counters.
|
|
65
65
|
poolWaitAttempts: 0,
|
|
66
|
-
awaitItemsAttempts: 0
|
|
66
|
+
awaitItemsAttempts: 0,
|
|
67
|
+
|
|
68
|
+
// Placeholders to destroy after ajaxify navigation settles.
|
|
69
|
+
toDestroyIds: []
|
|
67
70
|
};
|
|
68
71
|
|
|
69
72
|
function normalizeBool(v) {
|
|
@@ -263,8 +266,8 @@
|
|
|
263
266
|
state.usedPosts.forEach(function (id) { ids.push(id); });
|
|
264
267
|
state.usedCategories.forEach(function (id) { ids.push(id); });
|
|
265
268
|
|
|
266
|
-
//
|
|
267
|
-
|
|
269
|
+
// Return ids; destruction is performed after ajaxify.end settles.
|
|
270
|
+
return ids;
|
|
268
271
|
}
|
|
269
272
|
|
|
270
273
|
function patchShowAds() {
|
|
@@ -450,7 +453,9 @@
|
|
|
450
453
|
var wrap = null;
|
|
451
454
|
|
|
452
455
|
if (pick.recycled && pick.recycled.wrap) {
|
|
453
|
-
// Recycle:
|
|
456
|
+
// Recycle: destroy the old placeholder definition (after ajaxify has settled)
|
|
457
|
+
// so Ezoic can define it again at the new location.
|
|
458
|
+
if (sessionDefinedIds.has(id)) destroyPlaceholderIds([id]);
|
|
454
459
|
|
|
455
460
|
// Remove old wrapper.
|
|
456
461
|
var oldWrap = pick.recycled.wrap;
|
|
@@ -461,7 +466,7 @@
|
|
|
461
466
|
if (!wrap) continue;
|
|
462
467
|
|
|
463
468
|
// Give Ezoic a moment after DOM insertion.
|
|
464
|
-
setTimeoutTracked(function () { callShowAdsWhenReady(id); },
|
|
469
|
+
setTimeoutTracked(function () { callShowAdsWhenReady(id); }, 250);
|
|
465
470
|
} else {
|
|
466
471
|
usedSet.add(id);
|
|
467
472
|
wrap = insertAfter(el, id, kindClass, afterPos);
|
|
@@ -523,6 +528,9 @@
|
|
|
523
528
|
state.obs = null;
|
|
524
529
|
}
|
|
525
530
|
|
|
531
|
+
// Collect ids used on the page we are leaving.
|
|
532
|
+
state.toDestroyIds = destroyUsedPlaceholders();
|
|
533
|
+
|
|
526
534
|
// NOTE: Do NOT call ezstandalone.destroyPlaceholders() during ajaxify navigation.
|
|
527
535
|
// In practice this can leave Ezoic in a state where new placeholders stay "unused"
|
|
528
536
|
// until a full page reload. We only remove our wrappers.
|
|
@@ -778,6 +786,15 @@
|
|
|
778
786
|
|
|
779
787
|
// Delay gate to avoid racing NodeBB DOM swap vs Ezoic processing.
|
|
780
788
|
setTimeoutTracked(function () {
|
|
789
|
+
// After navigation, destroy placeholders that were used on the previous page
|
|
790
|
+
// so Ezoic can re-define them on this new page.
|
|
791
|
+
try {
|
|
792
|
+
if (state.toDestroyIds && state.toDestroyIds.length) {
|
|
793
|
+
destroyPlaceholderIds(state.toDestroyIds);
|
|
794
|
+
}
|
|
795
|
+
} catch (e) {}
|
|
796
|
+
state.toDestroyIds = [];
|
|
797
|
+
|
|
781
798
|
state.canShowAds = true;
|
|
782
799
|
waitForEzoicThenRun();
|
|
783
800
|
}, 300);
|