nodebb-plugin-ezoic-infinite 0.7.2 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Ezoic ads with infinite scroll using a pool of placeholder IDs",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
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
 
@@ -160,6 +198,7 @@ function callEzoic(ids) {
160
198
  return false;
161
199
  };
162
200
 
201
+ setupAdAutoHeight();
163
202
  window.ezstandalone.cmd.push(function () { run(); });
164
203
 
165
204
  let tries = 0;
@@ -315,9 +354,9 @@ function debounceRefresh() {
315
354
  debounceTimer = setTimeout(refreshAds, 220);
316
355
  }
317
356
 
318
- $(document).ready(debounceRefresh);
357
+ $(document).ready(function(){ setupAdAutoHeight(); debounceRefresh(); });
319
358
  $(window).on('action:ajaxify.end action:posts.loaded action:topic.loaded action:topics.loaded action:category.loaded', debounceRefresh);
320
- setTimeout(debounceRefresh, 2200);
359
+ setTimeout(function(){ setupAdAutoHeight(); debounceRefresh(); }, 2200);
321
360
 
322
361
  // Fallback: some themes/devices don't emit the expected events for infinite scroll.
323
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-post{margin:0.75rem 0;}
2
- .ezoic-ad-message-inner{padding:0.75rem 0;}
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;}