nodebb-plugin-ezoic-infinite 1.6.84 → 1.6.85

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": "1.6.84",
3
+ "version": "1.6.85",
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
@@ -9,8 +9,6 @@
9
9
 
10
10
  let config = null;
11
11
  let isInternalChange = false;
12
- let ezEnabled = false;
13
- let definedIds = new Set();
14
12
 
15
13
  function getPool() {
16
14
  let p = document.getElementById(POOL_ID);
@@ -28,59 +26,45 @@
28
26
  const id = parseInt(pid, 10);
29
27
  if (isNaN(id)) return;
30
28
 
31
- try {
32
- // 1. On définit TOUJOURS l'ID avant toute autre action
29
+ // On utilise la queue que tu as définie dans ton header
30
+ window.ezstandalone.cmd.push(function() {
33
31
  window.ezstandalone.define(id);
34
- definedIds.add(id);
35
-
36
- // 2. Si c'est la toute première fois de la page
37
- if (!ezEnabled) {
32
+
33
+ // On laisse Ezoic décider s'il doit faire enable() ou refresh()
34
+ if (!window.ezstandalone.enabled) {
38
35
  window.ezstandalone.enable();
39
36
  window.ezstandalone.display();
40
- ezEnabled = true;
41
- console.log('[Ezoic-Infinite] Initialized with ID:', id);
42
37
  } else {
43
- // 3. Sinon, on utilise refresh avec un léger délai
44
- // pour s'assurer que le navigateur a fini de dessiner le DIV
45
- setTimeout(() => {
46
- const el = document.getElementById('ezoic-pub-ad-placeholder-' + id);
47
- if (el) {
48
- window.ezstandalone.refresh();
49
- console.log('[Ezoic-Infinite] Refresh called for:', id);
50
- }
51
- }, 300);
38
+ // On utilise refresh uniquement si l'ID est déjà affiché
39
+ // ou si le cycle initial est terminé.
40
+ window.ezstandalone.refresh();
52
41
  }
53
- } catch (e) {
54
- console.warn('[Ezoic-Infinite] JS Error:', e.message);
55
- }
42
+ });
56
43
  }
57
44
 
58
45
  function redistribute() {
59
46
  if (!config || config.excluded) return;
60
47
 
61
- // Ciblage Harmony NodeBB 4
48
+ // Sélecteurs NodeBB 4.x Harmony
49
+ // TopicItems = Lignes de sujets sur l'accueil
50
+ // PostItems = Messages dans un sujet
62
51
  const topicItems = document.querySelectorAll('[component="category/topic"]');
63
52
  const postItems = document.querySelectorAll('[component="post"]');
64
53
 
65
- let items = [], kind = '', interval = 10, showFirst = false;
66
-
67
54
  if (topicItems.length > 0 && config.enableBetweenAds) {
68
- items = Array.from(topicItems);
69
- kind = 'between';
70
- interval = parseInt(config.intervalPosts, 10);
71
- showFirst = config.showFirstTopicAd;
72
- } else if (postItems.length > 0 && config.enableMessageAds) {
73
- items = Array.from(postItems);
74
- kind = 'message';
75
- interval = parseInt(config.messageIntervalPosts, 10);
76
- showFirst = config.showFirstMessageAd;
55
+ processItems(Array.from(topicItems), 'between', config.intervalPosts, config.showFirstTopicAd);
77
56
  }
57
+
58
+ if (postItems.length > 0 && config.enableMessageAds) {
59
+ processItems(Array.from(postItems), 'message', config.messageIntervalPosts, config.showFirstMessageAd);
60
+ }
61
+ }
78
62
 
79
- if (items.length === 0) return;
80
-
63
+ function processItems(items, kind, interval, showFirst) {
64
+ const int = parseInt(interval, 10) || 10;
81
65
  items.forEach((item, index) => {
82
66
  const pos = index + 1;
83
- const shouldHaveAd = (pos === 1 && showFirst) || (pos % interval === 0);
67
+ const shouldHaveAd = (pos === 1 && showFirst) || (pos % int === 0);
84
68
 
85
69
  const next = item.nextElementSibling;
86
70
  if (shouldHaveAd && !(next && next.classList.contains(WRAP_CLASS))) {
@@ -88,9 +72,7 @@
88
72
  const available = pool.querySelector(`.${WRAP_CLASS}[data-kind="${kind}"]`);
89
73
  if (available) {
90
74
  isInternalChange = true;
91
- // Insertion physique dans le DOM
92
75
  item.parentNode.insertBefore(available, item.nextSibling);
93
- // Activation Ezoic
94
76
  callEzoic(available.getAttribute('data-placeholder-id'));
95
77
  setTimeout(() => { isInternalChange = false; }, 100);
96
78
  }
@@ -129,6 +111,11 @@
129
111
  });
130
112
  }
131
113
 
114
+ // Gestion de la navigation AJAX de NodeBB 4
115
+ window.addEventListener('action:ajaxify.end', function() {
116
+ setTimeout(redistribute, 500);
117
+ });
118
+
132
119
  if (document.readyState === 'loading') {
133
120
  document.addEventListener('DOMContentLoaded', init);
134
121
  } else {
package/public/style.css CHANGED
@@ -1,18 +1,25 @@
1
1
  .nodebb-ezoic-wrap {
2
2
  display: block !important;
3
3
  width: 100% !important;
4
- margin: 30px 0 !important;
5
- min-height: 250px; /* Taille minimum pour forcer le chargement */
4
+ margin: 25px auto !important;
5
+ min-height: 250px; /* Réserve l'espace pour éviter les sauts de page */
6
6
  clear: both;
7
- overflow: visible !important;
7
+ text-align: center;
8
8
  }
9
9
 
10
- .nodebb-ezoic-wrap .ezoic-ad {
11
- min-width: 1px;
12
- min-height: 1px;
10
+ /* Accueil : Ajout d'une séparation propre entre les lignes de sujets */
11
+ [component="category/topic"] + .nodebb-ezoic-wrap {
12
+ border-bottom: 1px solid rgba(0,0,0,0.05);
13
+ margin-bottom: 15px !important;
13
14
  }
14
15
 
15
- /* Évite que les pubs se collent */
16
+ /* Cache si vide (Ezoic ajoute des classes quand il ne remplit pas) */
17
+ .nodebb-ezoic-wrap:empty {
18
+ display: none !important;
19
+ min-height: 0;
20
+ }
21
+
22
+ /* Anti-empilement */
16
23
  .nodebb-ezoic-wrap + .nodebb-ezoic-wrap {
17
24
  display: none !important;
18
25
  }