nodebb-plugin-ezoic-infinite 1.6.83 → 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.83",
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,7 +9,6 @@
9
9
 
10
10
  let config = null;
11
11
  let isInternalChange = false;
12
- let ezEnabled = false;
13
12
 
14
13
  function getPool() {
15
14
  let p = document.getElementById(POOL_ID);
@@ -25,45 +24,47 @@
25
24
  function callEzoic(pid) {
26
25
  if (typeof window.ezstandalone === 'undefined') return;
27
26
  const id = parseInt(pid, 10);
28
- try {
27
+ if (isNaN(id)) return;
28
+
29
+ // On utilise la queue que tu as définie dans ton header
30
+ window.ezstandalone.cmd.push(function() {
29
31
  window.ezstandalone.define(id);
30
- if (!ezEnabled) {
32
+
33
+ // On laisse Ezoic décider s'il doit faire enable() ou refresh()
34
+ if (!window.ezstandalone.enabled) {
31
35
  window.ezstandalone.enable();
32
36
  window.ezstandalone.display();
33
- ezEnabled = true;
34
37
  } else {
35
- // Délai pour s'assurer que le div est bien rendu par le navigateur
36
- setTimeout(() => { window.ezstandalone.refresh(); }, 200);
38
+ // On utilise refresh uniquement si l'ID est déjà affiché
39
+ // ou si le cycle initial est terminé.
40
+ window.ezstandalone.refresh();
37
41
  }
38
- } catch (e) { console.warn('[Ezoic] Error:', e); }
42
+ });
39
43
  }
40
44
 
41
45
  function redistribute() {
42
46
  if (!config || config.excluded) return;
43
47
 
44
- // Sélecteurs spécifiques à NodeBB 4.x / Harmony
48
+ // Sélecteurs NodeBB 4.x Harmony
49
+ // TopicItems = Lignes de sujets sur l'accueil
50
+ // PostItems = Messages dans un sujet
45
51
  const topicItems = document.querySelectorAll('[component="category/topic"]');
46
52
  const postItems = document.querySelectorAll('[component="post"]');
47
53
 
48
- let items = [], kind = '', interval = 10, showFirst = false;
49
-
50
54
  if (topicItems.length > 0 && config.enableBetweenAds) {
51
- items = Array.from(topicItems);
52
- kind = 'between';
53
- interval = parseInt(config.intervalPosts, 10);
54
- showFirst = config.showFirstTopicAd;
55
- } else if (postItems.length > 0 && config.enableMessageAds) {
56
- items = Array.from(postItems);
57
- kind = 'message';
58
- interval = parseInt(config.messageIntervalPosts, 10);
59
- showFirst = config.showFirstMessageAd;
55
+ processItems(Array.from(topicItems), 'between', config.intervalPosts, config.showFirstTopicAd);
60
56
  }
57
+
58
+ if (postItems.length > 0 && config.enableMessageAds) {
59
+ processItems(Array.from(postItems), 'message', config.messageIntervalPosts, config.showFirstMessageAd);
60
+ }
61
+ }
61
62
 
62
- if (items.length === 0) return;
63
-
63
+ function processItems(items, kind, interval, showFirst) {
64
+ const int = parseInt(interval, 10) || 10;
64
65
  items.forEach((item, index) => {
65
66
  const pos = index + 1;
66
- const shouldHaveAd = (pos === 1 && showFirst) || (pos % interval === 0);
67
+ const shouldHaveAd = (pos === 1 && showFirst) || (pos % int === 0);
67
68
 
68
69
  const next = item.nextElementSibling;
69
70
  if (shouldHaveAd && !(next && next.classList.contains(WRAP_CLASS))) {
@@ -103,7 +104,6 @@
103
104
 
104
105
  redistribute();
105
106
 
106
- // On surveille les changements de page et l'infinite scroll
107
107
  const observer = new MutationObserver(() => {
108
108
  if (!isInternalChange) redistribute();
109
109
  });
@@ -111,6 +111,11 @@
111
111
  });
112
112
  }
113
113
 
114
+ // Gestion de la navigation AJAX de NodeBB 4
115
+ window.addEventListener('action:ajaxify.end', function() {
116
+ setTimeout(redistribute, 500);
117
+ });
118
+
114
119
  if (document.readyState === 'loading') {
115
120
  document.addEventListener('DOMContentLoaded', init);
116
121
  } else {
package/public/style.css CHANGED
@@ -1,20 +1,25 @@
1
- /* Style du container injecté */
2
1
  .nodebb-ezoic-wrap {
3
2
  display: block !important;
4
3
  width: 100% !important;
5
- margin: 30px 0 !important;
6
- min-height: 100px; /* Force un espace pour qu'Ezoic puisse injecter */
4
+ margin: 25px auto !important;
5
+ min-height: 250px; /* Réserve l'espace pour éviter les sauts de page */
7
6
  clear: both;
7
+ text-align: center;
8
8
  }
9
9
 
10
- /* ANTI-PILLUP : Interdit deux pubs consécutives */
11
- .nodebb-ezoic-wrap + .nodebb-ezoic-wrap {
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;
14
+ }
15
+
16
+ /* Cache si vide (Ezoic ajoute des classes quand il ne remplit pas) */
17
+ .nodebb-ezoic-wrap:empty {
12
18
  display: none !important;
19
+ min-height: 0;
13
20
  }
14
21
 
15
- /* Alignement Harmony */
16
- [component="category/topic"] + .nodebb-ezoic-wrap,
17
- [component="post"] + .nodebb-ezoic-wrap {
18
- border-top: 1px solid rgba(0,0,0,0.05);
19
- padding: 15px 0;
22
+ /* Anti-empilement */
23
+ .nodebb-ezoic-wrap + .nodebb-ezoic-wrap {
24
+ display: none !important;
20
25
  }