nodebb-plugin-ezoic-infinite 1.6.62 → 1.6.63
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 +26 -13
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -965,30 +965,43 @@
|
|
|
965
965
|
const kind = getKind();
|
|
966
966
|
let inserted = 0;
|
|
967
967
|
|
|
968
|
+
// When the user is scrolling UP, NodeBB loads content above the viewport.
|
|
969
|
+
// Injecting new ad wraps at that moment targets those freshly-loaded top items
|
|
970
|
+
// (low ordinals) and makes ads appear right at the top of the list.
|
|
971
|
+
// While scrolling up we only restore previously-hidden wraps (pruneOrphanWraps
|
|
972
|
+
// un-hides them as their anchor posts return) — no new injections.
|
|
973
|
+
const canInject = scrollDir >= 0;
|
|
974
|
+
|
|
968
975
|
if (kind === 'topic' && normalizeBool(cfg.enableMessageAds)) {
|
|
969
976
|
const items = getPostContainers();
|
|
970
977
|
pruneOrphanWraps('ezoic-ad-message', items);
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
978
|
+
if (canInject) {
|
|
979
|
+
inserted += injectBetween('ezoic-ad-message', items,
|
|
980
|
+
Math.max(1, parseInt(cfg.messageIntervalPosts, 10) || 3),
|
|
981
|
+
normalizeBool(cfg.showFirstMessageAd), state.allPosts, 'curPosts');
|
|
982
|
+
decluster('ezoic-ad-message');
|
|
983
|
+
}
|
|
975
984
|
|
|
976
985
|
} else if (kind === 'categoryTopics' && normalizeBool(cfg.enableBetweenAds)) {
|
|
977
986
|
const items = getTopicItems();
|
|
978
987
|
pruneOrphanWraps('ezoic-ad-between', items);
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
988
|
+
if (canInject) {
|
|
989
|
+
inserted += injectBetween('ezoic-ad-between', items,
|
|
990
|
+
Math.max(1, parseInt(cfg.intervalPosts, 10) || 6),
|
|
991
|
+
normalizeBool(cfg.showFirstTopicAd), state.allTopics, 'curTopics');
|
|
992
|
+
decluster('ezoic-ad-between');
|
|
993
|
+
schedulePileFix();
|
|
994
|
+
}
|
|
984
995
|
|
|
985
996
|
} else if (kind === 'categories' && normalizeBool(cfg.enableCategoryAds)) {
|
|
986
997
|
const items = getCategoryItems();
|
|
987
998
|
pruneOrphanWraps('ezoic-ad-categories', items);
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
999
|
+
if (canInject) {
|
|
1000
|
+
inserted += injectBetween('ezoic-ad-categories', items,
|
|
1001
|
+
Math.max(1, parseInt(cfg.intervalCategories, 10) || 4),
|
|
1002
|
+
normalizeBool(cfg.showFirstCategoryAd), state.allCategories, 'curCategories');
|
|
1003
|
+
decluster('ezoic-ad-categories');
|
|
1004
|
+
}
|
|
992
1005
|
}
|
|
993
1006
|
|
|
994
1007
|
return inserted;
|