nodebb-plugin-ezoic-infinite 1.6.72 → 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 +2 -2
- package/public/client.js +35 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-ezoic-infinite",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.74",
|
|
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
|
@@ -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];
|
|
@@ -741,7 +763,12 @@ function globalGapFixInit() {
|
|
|
741
763
|
// For message/topic pages we may prune filled or empty orphans if they are far away,
|
|
742
764
|
// otherwise consecutive "stacks" can appear when posts are virtualized.
|
|
743
765
|
const isMessage = (kindClass === 'ezoic-ad-message');
|
|
744
|
-
|
|
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).
|
|
745
772
|
|
|
746
773
|
// Never prune a fresh wrap: it may fill late.
|
|
747
774
|
try {
|
|
@@ -759,6 +786,7 @@ if (hasNearbyItem(wrap)) {
|
|
|
759
786
|
try { wrap.classList && wrap.classList.add('ez-orphan-hidden'); wrap.style && (wrap.style.display = 'none'); } catch (e) {}
|
|
760
787
|
|
|
761
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.
|
|
762
790
|
if (isMessage) {
|
|
763
791
|
try {
|
|
764
792
|
const r = wrap.getBoundingClientRect();
|
|
@@ -771,6 +799,9 @@ if (isMessage) {
|
|
|
771
799
|
}
|
|
772
800
|
}
|
|
773
801
|
|
|
802
|
+
// Never release filled wraps on non-message lists; hiding is enough to prevent stacks.
|
|
803
|
+
if (!isMessage && isFilled(wrap)) return;
|
|
804
|
+
|
|
774
805
|
withInternalDomChange(() => releaseWrapNode(wrap));
|
|
775
806
|
removed++;
|
|
776
807
|
});
|
|
@@ -1019,6 +1050,8 @@ removed++;
|
|
|
1019
1050
|
watchWrapForFill(ww);
|
|
1020
1051
|
setTimeout(() => { try { tightenEzoicMinHeight(ww); } catch (e) {} }, 900);
|
|
1021
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);
|
|
1022
1055
|
}
|
|
1023
1056
|
} catch (e) {}
|
|
1024
1057
|
setTimeout(() => { clearTimeout(hardTimer); release(); }, 650);
|
|
@@ -1091,21 +1124,6 @@ function buildOrdinalMap(items) {
|
|
|
1091
1124
|
const el = ordinalMap.get(afterPos);
|
|
1092
1125
|
if (!el) continue;
|
|
1093
1126
|
if (!el || !el.isConnected) continue;
|
|
1094
|
-
|
|
1095
|
-
// Viewport guard (loose): NodeBB may load batches above the fold when the user scrolls up.
|
|
1096
|
-
// If we inject immediately into anchors that are *far* above the viewport, wraps tend to
|
|
1097
|
-
// accumulate/pile near the top once the DOM is recycled.
|
|
1098
|
-
//
|
|
1099
|
-
// Important: do NOT skip when the anchor is only slightly above the viewport (e.g. -10px),
|
|
1100
|
-
// otherwise injection feels "missing" compared to v17. We only skip when it's well above.
|
|
1101
|
-
try {
|
|
1102
|
-
if (scrollDir < 0) {
|
|
1103
|
-
const bottom = el.getBoundingClientRect().bottom;
|
|
1104
|
-
const cutoff = -Math.max(240, (window.innerHeight || 800) * 0.75);
|
|
1105
|
-
if (bottom < cutoff) continue;
|
|
1106
|
-
}
|
|
1107
|
-
} catch (e) {}
|
|
1108
|
-
|
|
1109
1127
|
if (isAdjacentAd(el)) continue;
|
|
1110
1128
|
if (findWrap(kindClass, afterPos)) continue;
|
|
1111
1129
|
|