nodebb-plugin-ezoic-infinite 0.7.1 → 0.7.3
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 +48 -12
- package/public/style.css +5 -2
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -139,6 +139,44 @@ function removeOldestCategoryAd() {
|
|
|
139
139
|
return true;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
|
|
143
|
+
function setupAdAutoHeight() {
|
|
144
|
+
if (window.__ezoicAutoHeightAttached) return;
|
|
145
|
+
window.__ezoicAutoHeightAttached = true;
|
|
146
|
+
|
|
147
|
+
try {
|
|
148
|
+
const ro = new ResizeObserver(function (entries) {
|
|
149
|
+
for (const entry of entries) {
|
|
150
|
+
const el = entry.target;
|
|
151
|
+
el.style.minHeight = '0px';
|
|
152
|
+
el.style.height = 'auto';
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
function attach() {
|
|
157
|
+
document.querySelectorAll('.ezoic-ad').forEach(function (wrap) {
|
|
158
|
+
if (wrap.__ezoicRO) return;
|
|
159
|
+
wrap.__ezoicRO = true;
|
|
160
|
+
ro.observe(wrap);
|
|
161
|
+
|
|
162
|
+
const ph = wrap.querySelector('[id^="ezoic-pub-ad-placeholder-"]');
|
|
163
|
+
if (ph && ph.firstElementChild && !ph.firstElementChild.__ezoicRO) {
|
|
164
|
+
ph.firstElementChild.__ezoicRO = true;
|
|
165
|
+
ro.observe(ph.firstElementChild);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
attach();
|
|
171
|
+
setTimeout(attach, 500);
|
|
172
|
+
setTimeout(attach, 1500);
|
|
173
|
+
setTimeout(attach, 3000);
|
|
174
|
+
|
|
175
|
+
const mo = new MutationObserver(function () { attach(); });
|
|
176
|
+
mo.observe(document.body, { childList: true, subtree: true });
|
|
177
|
+
} catch (e) {}
|
|
178
|
+
}
|
|
179
|
+
|
|
142
180
|
function callEzoic(ids) {
|
|
143
181
|
if (!ids || !ids.length) return;
|
|
144
182
|
|
|
@@ -146,6 +184,11 @@ function callEzoic(ids) {
|
|
|
146
184
|
window.ezstandalone.cmd = window.ezstandalone.cmd || [];
|
|
147
185
|
|
|
148
186
|
const run = function () {
|
|
187
|
+
try {
|
|
188
|
+
if (typeof window.ezstandalone.destroyPlaceholders === 'function') {
|
|
189
|
+
window.ezstandalone.destroyPlaceholders.apply(window.ezstandalone, ids);
|
|
190
|
+
}
|
|
191
|
+
} catch (e) {}
|
|
149
192
|
try {
|
|
150
193
|
if (typeof window.ezstandalone.showAds === 'function') {
|
|
151
194
|
window.ezstandalone.showAds.apply(window.ezstandalone, ids);
|
|
@@ -155,6 +198,7 @@ function callEzoic(ids) {
|
|
|
155
198
|
return false;
|
|
156
199
|
};
|
|
157
200
|
|
|
201
|
+
setupAdAutoHeight();
|
|
158
202
|
window.ezstandalone.cmd.push(function () { run(); });
|
|
159
203
|
|
|
160
204
|
let tries = 0;
|
|
@@ -198,11 +242,7 @@ function injectTopicMessageAds($posts, pool, interval) {
|
|
|
198
242
|
if (seenAfterPostNo.has(postNo)) return;
|
|
199
243
|
|
|
200
244
|
let id = pickNextId(pool);
|
|
201
|
-
if (!id) {
|
|
202
|
-
if (!removeOldestTopicAd()) return;
|
|
203
|
-
id = pickNextId(pool);
|
|
204
|
-
if (!id) return;
|
|
205
|
-
}
|
|
245
|
+
if (!id) { return; }
|
|
206
246
|
|
|
207
247
|
const inner = '<div class="ezoic-ad-message-inner"><div id="ezoic-pub-ad-placeholder-' + id + '"></div></div>';
|
|
208
248
|
const html = makeWrapperLike(
|
|
@@ -237,11 +277,7 @@ function injectCategoryBetweenAds($items, pool, interval) {
|
|
|
237
277
|
if (seenAfterTopicPos.has(pos)) return;
|
|
238
278
|
|
|
239
279
|
let id = pickNextId(pool);
|
|
240
|
-
if (!id) {
|
|
241
|
-
if (!removeOldestCategoryAd()) return;
|
|
242
|
-
id = pickNextId(pool);
|
|
243
|
-
if (!id) return;
|
|
244
|
-
}
|
|
280
|
+
if (!id) { return; }
|
|
245
281
|
|
|
246
282
|
const placeholder = '<div id="ezoic-pub-ad-placeholder-' + id + '"></div>';
|
|
247
283
|
const html = makeWrapperLike(
|
|
@@ -318,9 +354,9 @@ function debounceRefresh() {
|
|
|
318
354
|
debounceTimer = setTimeout(refreshAds, 220);
|
|
319
355
|
}
|
|
320
356
|
|
|
321
|
-
$(document).ready(debounceRefresh);
|
|
357
|
+
$(document).ready(function(){ setupAdAutoHeight(); debounceRefresh(); });
|
|
322
358
|
$(window).on('action:ajaxify.end action:posts.loaded action:topic.loaded action:topics.loaded action:category.loaded', debounceRefresh);
|
|
323
|
-
setTimeout(debounceRefresh, 2200);
|
|
359
|
+
setTimeout(function(){ setupAdAutoHeight(); debounceRefresh(); }, 2200);
|
|
324
360
|
|
|
325
361
|
// Fallback: some themes/devices don't emit the expected events for infinite scroll.
|
|
326
362
|
// Observe DOM additions and trigger a refresh when new posts/topics are appended/prepended.
|
package/public/style.css
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
.ezoic-ad-
|
|
2
|
-
.ezoic-ad-
|
|
1
|
+
.ezoic-ad{min-height:0 !important;height:auto !important;padding:0 !important;}
|
|
2
|
+
.ezoic-ad-post{margin:0.5rem 0;}
|
|
3
|
+
.ezoic-ad-topic{margin:0.5rem 0;}
|
|
4
|
+
.ezoic-ad-message-inner{padding:0;margin:0;}
|
|
5
|
+
.ezoic-ad-message-inner > div{margin:0;padding:0;}
|