nodebb-plugin-ezoic-infinite 1.4.67 → 1.4.68

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/client.js +33 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.4.67",
3
+ "version": "1.4.68",
4
4
  "description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/public/client.js CHANGED
@@ -139,20 +139,33 @@
139
139
  function cleanupInvisibleEzoicElements() {
140
140
  try {
141
141
  document.querySelectorAll('.ezoic-ad').forEach(wrapper => {
142
- // Supprimer éléments invisibles après le placeholder
143
- wrapper.querySelectorAll('*').forEach(el => {
144
- if (el.id && el.id.startsWith('ezoic-pub-ad-placeholder-')) return;
145
-
146
- const rect = el.getBoundingClientRect();
147
- const computed = window.getComputedStyle(el);
148
-
149
- // Élément invisible mais prend de l'espace
150
- if (
151
- (computed.display !== 'none' && computed.visibility !== 'hidden') &&
152
- (rect.height === 0 || computed.opacity === '0') &&
153
- el.children.length === 0
154
- ) {
155
- el.remove();
142
+ const ph = wrapper.querySelector('[id^="ezoic-pub-ad-placeholder-"]');
143
+ if (!ph) return;
144
+
145
+ // Supprimer TOUS les éléments après le placeholder rempli
146
+ // qui créent de l'espace vertical
147
+ let found = false;
148
+ Array.from(wrapper.children).forEach(child => {
149
+ if (child === ph || child.contains(ph)) {
150
+ found = true;
151
+ return;
152
+ }
153
+
154
+ // Si élément APRÈS le placeholder
155
+ if (found) {
156
+ const rect = child.getBoundingClientRect();
157
+ const computed = window.getComputedStyle(child);
158
+
159
+ // Supprimer si:
160
+ // 1. Height > 0 mais pas de texte/image visible
161
+ // 2. Ou opacity: 0
162
+ // 3. Ou visibility: hidden
163
+ const hasContent = child.textContent.trim().length > 0 ||
164
+ child.querySelector('img, iframe, video');
165
+
166
+ if (!hasContent || computed.opacity === '0' || computed.visibility === 'hidden') {
167
+ child.remove();
168
+ }
156
169
  }
157
170
  });
158
171
  });
@@ -169,7 +182,7 @@
169
182
  if (ph.children.length === 0) {
170
183
  wrapper.remove();
171
184
  }
172
- }, 3000);
185
+ }, 1500);
173
186
  }
174
187
  });
175
188
  } catch (e) {}
@@ -397,6 +410,11 @@
397
410
  }
398
411
  });
399
412
  } catch (e) {}
413
+
414
+ // CRITIQUE: Nettoyer éléments invisibles APRÈS que pubs soient chargées
415
+ setTimeout(() => {
416
+ cleanupInvisibleEzoicElements();
417
+ }, 800); // 1.5s pour laisser Ezoic charger
400
418
  }, 100);
401
419
  }
402
420