nodebb-plugin-ezoic-infinite 1.6.73 → 1.6.74
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 +39 -13
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -133,7 +133,29 @@ function tightenEzoicMinHeight(wrap) {
|
|
|
133
133
|
if (!wrap || !wrap.querySelector) return;
|
|
134
134
|
|
|
135
135
|
const iframes = wrap.querySelectorAll('iframe');
|
|
136
|
-
|
|
136
|
+
|
|
137
|
+
// If the wrap is still empty, Ezoic often leaves inline `min-height:400px !important` on
|
|
138
|
+
// nested `.ezoic-ad` containers, which creates large blank gaps. We can't remove it with CSS.
|
|
139
|
+
// We collapse those gaps after a short grace period, while still allowing late fill.
|
|
140
|
+
if (!iframes || !iframes.length) {
|
|
141
|
+
try {
|
|
142
|
+
const created = parseInt(wrap.getAttribute('data-created') || '0', 10);
|
|
143
|
+
const age = created ? (now() - created) : 0;
|
|
144
|
+
// Give auctions/CMP a bit of time; then collapse the notorious 400px gap.
|
|
145
|
+
if (age >= 12000) {
|
|
146
|
+
const nodes = wrap.querySelectorAll('.ezoic-ad, .ezoic-ad-adaptive');
|
|
147
|
+
nodes.forEach((n) => {
|
|
148
|
+
const st = (n.getAttribute('style') || '').toLowerCase();
|
|
149
|
+
if (st.includes('min-height:400') || st.includes('min-height: 400') || st.includes('min-height:400px')) {
|
|
150
|
+
try { n.style.setProperty('min-height', '1px', 'important'); } catch (e) { n.style.minHeight = '1px'; }
|
|
151
|
+
try { n.style.setProperty('height', 'auto', 'important'); } catch (e) {}
|
|
152
|
+
try { n.style.setProperty('line-height', '0', 'important'); } catch (e) {}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
} catch (e) {}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
137
159
|
|
|
138
160
|
// Find the closest "big" ezoic container that carries the 400px min-height.
|
|
139
161
|
const firstIframe = iframes[0];
|
|
@@ -738,17 +760,15 @@ function globalGapFixInit() {
|
|
|
738
760
|
if (wrap.getAttribute('data-ezoic-pin') === '1') return;
|
|
739
761
|
} catch (e) {}
|
|
740
762
|
|
|
741
|
-
// For message pages
|
|
742
|
-
//
|
|
743
|
-
// temporarily leave the DOM (especially on /category/... lists).
|
|
744
|
-
//
|
|
745
|
-
// Strategy:
|
|
746
|
-
// - always hide orphan wraps (filled or empty) when their anchor item is gone
|
|
747
|
-
// - only *release* (remove) them if they are far offscreen, to avoid "vanishing" feel
|
|
763
|
+
// For message/topic pages we may prune filled or empty orphans if they are far away,
|
|
764
|
+
// otherwise consecutive "stacks" can appear when posts are virtualized.
|
|
748
765
|
const isMessage = (kindClass === 'ezoic-ad-message');
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
766
|
+
// IMPORTANT:
|
|
767
|
+
// On category/topic lists, NodeBB can virtualize/recycle list items while scrolling.
|
|
768
|
+
// If we keep *filled* wraps when their anchor items are gone, they can visually
|
|
769
|
+
// "stack" together on upward scroll. We therefore allow filled wraps to be hidden
|
|
770
|
+
// when orphaned, but we still avoid fully releasing them (so they can come back
|
|
771
|
+
// when anchors reappear).
|
|
752
772
|
|
|
753
773
|
// Never prune a fresh wrap: it may fill late.
|
|
754
774
|
try {
|
|
@@ -765,8 +785,9 @@ if (hasNearbyItem(wrap)) {
|
|
|
765
785
|
// back-to-back while scrolling. We'll recycle it when its anchor comes back.
|
|
766
786
|
try { wrap.classList && wrap.classList.add('ez-orphan-hidden'); wrap.style && (wrap.style.display = 'none'); } catch (e) {}
|
|
767
787
|
|
|
768
|
-
// For message ads
|
|
769
|
-
|
|
788
|
+
// For message ads: only release if far offscreen to avoid perceived "vanishing" during fast scroll.
|
|
789
|
+
// For non-message lists (topics/categories): do not release filled wraps at all; only hide.
|
|
790
|
+
if (isMessage) {
|
|
770
791
|
try {
|
|
771
792
|
const r = wrap.getBoundingClientRect();
|
|
772
793
|
const vh = Math.max(1, window.innerHeight || 1);
|
|
@@ -778,6 +799,9 @@ if (isMessage || isTopicList) {
|
|
|
778
799
|
}
|
|
779
800
|
}
|
|
780
801
|
|
|
802
|
+
// Never release filled wraps on non-message lists; hiding is enough to prevent stacks.
|
|
803
|
+
if (!isMessage && isFilled(wrap)) return;
|
|
804
|
+
|
|
781
805
|
withInternalDomChange(() => releaseWrapNode(wrap));
|
|
782
806
|
removed++;
|
|
783
807
|
});
|
|
@@ -1026,6 +1050,8 @@ removed++;
|
|
|
1026
1050
|
watchWrapForFill(ww);
|
|
1027
1051
|
setTimeout(() => { try { tightenEzoicMinHeight(ww); } catch (e) {} }, 900);
|
|
1028
1052
|
setTimeout(() => { try { tightenEzoicMinHeight(ww); } catch (e) {} }, 2200);
|
|
1053
|
+
// Collapse the notorious 400px inline min-height if the slot stays empty.
|
|
1054
|
+
setTimeout(() => { try { tightenEzoicMinHeight(ww); } catch (e) {} }, 12500);
|
|
1029
1055
|
}
|
|
1030
1056
|
} catch (e) {}
|
|
1031
1057
|
setTimeout(() => { clearTimeout(hardTimer); release(); }, 650);
|