nodebb-plugin-ezoic-infinite 1.6.80 → 1.6.81

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/library.js CHANGED
@@ -8,12 +8,12 @@ const SETTINGS_KEY = 'ezoic-infinite';
8
8
  const plugin = {};
9
9
 
10
10
  async function getSettings() {
11
- return await meta.settings.get(SETTINGS_KEY);
11
+ const settings = await meta.settings.get(SETTINGS_KEY);
12
+ return settings || {};
12
13
  }
13
14
 
14
15
  async function isUserExcluded(uid, excludedGroups) {
15
16
  if (!uid || !excludedGroups) return false;
16
- // Gérer le format multiple de NodeBB
17
17
  const groupsList = Array.isArray(excludedGroups) ? excludedGroups : [excludedGroups];
18
18
  if (!groupsList.length) return false;
19
19
  return await groups.isMemberOfGroups(uid, groupsList);
@@ -29,6 +29,7 @@ plugin.init = async ({ router, middleware }) => {
29
29
  res.render('admin/plugins/ezoic-infinite', {
30
30
  ...settings,
31
31
  allGroups,
32
+ // Helper pour le tpl
32
33
  enableBetweenAds_checked: settings.enableBetweenAds === 'on' ? 'checked' : '',
33
34
  enableMessageAds_checked: settings.enableMessageAds === 'on' ? 'checked' : ''
34
35
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.6.80",
3
+ "version": "1.6.81",
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
@@ -21,7 +21,7 @@
21
21
 
22
22
  let config = null;
23
23
  let isInternalChange = false;
24
- let ezEnabled = false; // Flag pour savoir si ezstandalone.enable() a été appelé
24
+ let ezInitialized = false; // Flag crucial pour éviter l'erreur de "refresh"
25
25
 
26
26
  function withInternalDomChange(fn) {
27
27
  isInternalChange = true;
@@ -40,7 +40,7 @@
40
40
  }
41
41
 
42
42
  function releaseWrapNode(wrap) {
43
- if (!wrap) return;
43
+ if (!wrap || !wrap.parentNode) return;
44
44
  const pool = getPool();
45
45
  wrap.classList.remove('ez-orphan-hidden');
46
46
  if (wrap.parentNode !== pool) {
@@ -48,6 +48,7 @@
48
48
  }
49
49
  }
50
50
 
51
+ // Anti-pillup : évite que deux pubs se suivent
51
52
  function decluster(container) {
52
53
  const wraps = Array.from(container.querySelectorAll(`.${WRAP_CLASS}`));
53
54
  wraps.forEach(wrap => {
@@ -58,6 +59,7 @@
58
59
  });
59
60
  }
60
61
 
62
+ // Nettoyage des pubs orphelines lors de la virtualisation
61
63
  function pruneOrphanWraps() {
62
64
  const wraps = document.querySelectorAll(`.${WRAP_CLASS}`);
63
65
  const items = document.querySelectorAll('[component="category/topic"], [component="post"]');
@@ -93,25 +95,28 @@
93
95
 
94
96
  function callEzoic(placeholderId) {
95
97
  if (typeof window.ezstandalone === 'undefined') return;
96
-
97
98
  const pid = parseInt(placeholderId, 10);
99
+ if (isNaN(pid)) return;
100
+
98
101
  try {
99
- if (!ezEnabled) {
102
+ if (!ezInitialized) {
103
+ // PREMIER APPEL : define + enable + display
100
104
  window.ezstandalone.define(pid);
101
105
  window.ezstandalone.enable();
102
106
  window.ezstandalone.display();
103
- ezEnabled = true;
107
+ ezInitialized = true;
104
108
  } else {
109
+ // APPELS SUIVANTS (Scroll) : define + refresh
105
110
  window.ezstandalone.define(pid);
106
- // Utiliser une petite pause pour être sûr que le DOM est prêt
111
+ // On attend que le DOM soit stable pour le refresh
107
112
  setTimeout(() => {
108
113
  if (document.getElementById('ezoic-pub-ad-placeholder-' + pid)) {
109
114
  window.ezstandalone.refresh();
110
115
  }
111
- }, 100);
116
+ }, 150);
112
117
  }
113
118
  } catch (e) {
114
- console.warn('[Ezoic-Infinite] Error refreshing ad:', e);
119
+ console.warn('[Ezoic-Infinite] Ez Error:', e.message);
115
120
  }
116
121
  }
117
122
 
@@ -178,7 +183,7 @@
178
183
  const pool = getPool();
179
184
  const setupPool = (idsRaw, kind) => {
180
185
  if (!idsRaw) return;
181
- const ids = idsRaw.split(/[\s,]+/).filter(Boolean);
186
+ const ids = idsRaw.split(/[\s,]+/).map(s => s.trim()).filter(Boolean);
182
187
  ids.forEach(id => {
183
188
  if (!document.querySelector(`[data-placeholder-id="${id}"]`)) {
184
189
  const d = document.createElement('div');
@@ -196,16 +201,17 @@
196
201
  setupPool(config.placeholderIds, 'between');
197
202
  setupPool(config.messagePlaceholderIds, 'message');
198
203
  cb();
199
- });
204
+ }).catch(e => console.error('[Ezoic] Config load error', e));
200
205
  }
201
206
 
202
207
  let timer = null;
203
208
  function schedule() {
204
209
  if (timer) clearTimeout(timer);
205
210
  timer = setTimeout(() => {
211
+ // Sélecteurs pour NodeBB 4.x / Harmony
206
212
  const lists = document.querySelectorAll('[component="category"], .topic-list, [component="topic"], [component="category/topic/list"]');
207
213
  lists.forEach(redistribute);
208
- }, 150); // Un peu plus de délai pour NodeBB 4.x
214
+ }, 200);
209
215
  }
210
216
 
211
217
  function init() {
@@ -214,7 +220,9 @@
214
220
  if (typeof MutationObserver !== 'undefined') {
215
221
  const mo = new MutationObserver((muts) => {
216
222
  if (isInternalChange) return;
217
- schedule();
223
+ // On vérifie si un élément structurel a été ajouté
224
+ const shouldRun = muts.some(m => m.addedNodes.length > 0);
225
+ if (shouldRun) schedule();
218
226
  });
219
227
  mo.observe(document.body, { childList: true, subtree: true });
220
228
  }
package/public/style.css CHANGED
@@ -1,37 +1,35 @@
1
+ /* Container principal */
1
2
  .nodebb-ezoic-wrap {
2
3
  display: block;
3
4
  width: 100%;
4
5
  margin: 20px 0 !important;
5
6
  padding: 0 !important;
6
7
  clear: both;
7
- overflow: visible;
8
- min-height: 50px; /* Aide Ezoic à détecter l'élément */
8
+ min-height: 50px; /* Important pour que l'ad-tester détecte le bloc */
9
9
  }
10
10
 
11
- /* Cache les pubs orphelines proprement */
11
+ /* Cache les pubs orphelines sans les supprimer du DOM */
12
12
  .nodebb-ezoic-wrap.ez-orphan-hidden {
13
13
  display: none !important;
14
14
  height: 0 !important;
15
15
  min-height: 0 !important;
16
16
  margin: 0 !important;
17
- padding: 0 !important;
18
17
  }
19
18
 
20
- /* Neutralisation du style interne Ezoic pour éviter les énormes espaces blancs */
19
+ /* Nettoyage des styles internes Ezoic */
21
20
  .nodebb-ezoic-wrap .ezoic-ad {
22
21
  margin: 0 auto !important;
23
22
  padding: 0 !important;
24
23
  min-height: 1px !important;
25
24
  height: auto !important;
26
- line-height: normal !important;
27
25
  }
28
26
 
29
- /* Enlève les marges doubles si plusieurs pubs se suivent malgré le script */
27
+ /* Neutralise les marges doubles */
30
28
  .nodebb-ezoic-wrap + .nodebb-ezoic-wrap {
31
29
  margin-top: 0 !important;
32
30
  }
33
31
 
34
- /* Assurer la visibilité pour l'IntersectionObserver d'Ezoic */
32
+ /* Évite les débordements sur mobile */
35
33
  .ezoic-ad iframe {
36
- max-width: 100%;
34
+ max-width: 100% !important;
37
35
  }