nodebb-plugin-ezoic-infinite 1.5.74 → 1.5.75
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 +73 -3
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -145,19 +145,88 @@ function tightenEzoicMinHeight(wrap) {
|
|
|
145
145
|
function watchWrapForFill(wrap) {
|
|
146
146
|
try {
|
|
147
147
|
if (!wrap || wrap.__ezFillObs) return;
|
|
148
|
-
|
|
148
|
+
|
|
149
|
+
// Ezoic can (re)apply inline styles after fill; keep tightening for a short window.
|
|
150
|
+
const start = now();
|
|
151
|
+
const tightenBurst = () => {
|
|
152
|
+
try { tightenEzoicMinHeight(wrap); } catch (e) {}
|
|
153
|
+
if (now() - start < 6000) {
|
|
154
|
+
setTimeout(tightenBurst, 350);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const obs = new MutationObserver((muts) => {
|
|
159
|
+
// If anything that looks like ad content appears, treat as filled.
|
|
149
160
|
if (isFilledNode(wrap)) {
|
|
150
161
|
wrap.classList.remove('is-empty');
|
|
151
|
-
|
|
162
|
+
tightenBurst();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// If Ezoic changes inline style on descendants (min-height:400!important), tighten again.
|
|
166
|
+
for (const m of muts) {
|
|
167
|
+
if (m.type === 'attributes' && m.attributeName === 'style') {
|
|
168
|
+
try { tightenEzoicMinHeight(wrap); } catch (e) {}
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Disconnect only after the burst window to avoid missing late style rewrites.
|
|
174
|
+
if (now() - start > 7000) {
|
|
152
175
|
try { obs.disconnect(); } catch (e) {}
|
|
153
176
|
wrap.__ezFillObs = null;
|
|
154
177
|
}
|
|
155
178
|
});
|
|
156
|
-
|
|
179
|
+
|
|
180
|
+
obs.observe(wrap, { childList: true, subtree: true, attributes: true, attributeFilter: ['style'] });
|
|
157
181
|
wrap.__ezFillObs = obs;
|
|
158
182
|
} catch (e) {}
|
|
159
183
|
}
|
|
160
184
|
|
|
185
|
+
// Global safety net: sometimes Ezoic swaps nodes in ways that bypass our per-wrap observers.
|
|
186
|
+
// When we see an Ezoic container with min-height:400!important inside posts/topics, shrink it.
|
|
187
|
+
function globalGapFixInit() {
|
|
188
|
+
try {
|
|
189
|
+
if (window.__nodebbEzoicGapFix) return;
|
|
190
|
+
window.__nodebbEzoicGapFix = true;
|
|
191
|
+
|
|
192
|
+
const inPostArea = (el) => {
|
|
193
|
+
try {
|
|
194
|
+
return !!(el && el.closest && el.closest('[component="post"], .topic, .posts, [component="topic"]'));
|
|
195
|
+
} catch (e) { return false; }
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const maybeFix = (root) => {
|
|
199
|
+
if (!root || !root.querySelectorAll) return;
|
|
200
|
+
const nodes = root.querySelectorAll('.ezoic-ad[style*="min-height"], .ezoic-ad-adaptive[style*="min-height"]');
|
|
201
|
+
nodes.forEach((n) => {
|
|
202
|
+
const st = (n.getAttribute('style') || '').toLowerCase();
|
|
203
|
+
if (!st.includes('min-height:400')) return;
|
|
204
|
+
if (!inPostArea(n)) return;
|
|
205
|
+
try {
|
|
206
|
+
const tmpWrap = n.closest('.' + WRAP_CLASS) || n.parentElement;
|
|
207
|
+
tightenEzoicMinHeight(tmpWrap || n);
|
|
208
|
+
} catch (e) {}
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
requestAnimationFrame(() => maybeFix(document));
|
|
213
|
+
|
|
214
|
+
const obs = new MutationObserver((muts) => {
|
|
215
|
+
for (const m of muts) {
|
|
216
|
+
const t = m.target;
|
|
217
|
+
if (m.type === 'attributes') {
|
|
218
|
+
maybeFix(t && t.nodeType === 1 ? t : t && t.parentElement);
|
|
219
|
+
} else if (m.addedNodes && m.addedNodes.length) {
|
|
220
|
+
m.addedNodes.forEach((n) => {
|
|
221
|
+
if (n && n.nodeType === 1) maybeFix(n);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
obs.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ['style'] });
|
|
227
|
+
} catch (e) {}
|
|
228
|
+
}
|
|
229
|
+
|
|
161
230
|
// ---------------- state ----------------
|
|
162
231
|
|
|
163
232
|
const state = {
|
|
@@ -1087,6 +1156,7 @@ function watchWrapForFill(wrap) {
|
|
|
1087
1156
|
|
|
1088
1157
|
warmUpNetwork();
|
|
1089
1158
|
patchShowAds();
|
|
1159
|
+
globalGapFixInit();
|
|
1090
1160
|
ensurePreloadObserver();
|
|
1091
1161
|
ensureDomObserver();
|
|
1092
1162
|
|