nodebb-plugin-ezoic-infinite 1.6.90 → 1.6.91

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 +17 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.6.90",
3
+ "version": "1.6.91",
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,14 +9,9 @@
9
9
 
10
10
  let config = null;
11
11
  let isInternalChange = false;
12
- let definedIds = new Set();
13
12
  let pendingIds = new Set();
14
13
  let refreshTimer = null;
15
14
 
16
- if (typeof window.ezoicFirstEnableDone === 'undefined') {
17
- window.ezoicFirstEnableDone = false;
18
- }
19
-
20
15
  function getPool() {
21
16
  let p = document.getElementById(POOL_ID);
22
17
  if (!p) {
@@ -35,21 +30,15 @@
35
30
  const idsToProcess = Array.from(pendingIds);
36
31
  pendingIds.clear();
37
32
 
33
+ // On enregistre les IDs
38
34
  window.ezstandalone.define(idsToProcess);
39
35
 
40
- if (!window.ezstandalone.enabled && !window.ezoicFirstEnableDone) {
41
- window.ezstandalone.enable();
42
- window.ezstandalone.display();
43
- window.ezoicFirstEnableDone = true;
44
- } else {
45
- // Délai de sécurité pour éviter le conflit "same page enable"
46
- setTimeout(function() {
47
- try {
48
- window.ezstandalone.refresh();
49
- } catch (e) {
50
- console.debug('[Ezoic] Refresh deferred');
51
- }
52
- }, 1000);
36
+ // On appelle UNIQUEMENT refresh.
37
+ // Si Ezoic n'est pas "enabled", il ignorera l'appel sans erreur bloquante.
38
+ try {
39
+ window.ezstandalone.refresh();
40
+ } catch (e) {
41
+ console.debug('[Ezoic] Refresh deferred');
53
42
  }
54
43
  });
55
44
  }
@@ -58,7 +47,6 @@
58
47
  const pid = parseInt(id, 10);
59
48
  if (isNaN(pid)) return;
60
49
  pendingIds.add(pid);
61
- definedIds.add(pid);
62
50
 
63
51
  clearTimeout(refreshTimer);
64
52
  refreshTimer = setTimeout(triggerEzoic, 300);
@@ -67,23 +55,19 @@
67
55
  function redistribute() {
68
56
  if (!config || config.excluded) return;
69
57
 
70
- // 1. PAGE D'ACCUEIL (Liste des catégories)
58
+ // 1. Accueil (Catégories)
71
59
  const categoryItems = document.querySelectorAll('.category-item, [component="categories/category"]');
72
-
73
- // 2. PAGE CATEGORIE (Liste des topics)
60
+ // 2. Liste Topics
74
61
  const topicItems = document.querySelectorAll('li[component="category/topic"]');
75
-
76
- // 3. PAGE TOPIC (Messages / Posts)
62
+ // 3. Messages
77
63
  const postItems = document.querySelectorAll('[component="post"]');
78
64
 
79
65
  if (categoryItems.length > 0 && config.enableCategoryAds) {
80
66
  process(Array.from(categoryItems), 'home', config.intervalCategories, config.showFirstCategoryAd);
81
67
  }
82
-
83
68
  if (topicItems.length > 0 && config.enableBetweenAds) {
84
69
  process(Array.from(topicItems), 'topic-list', config.intervalPosts, config.showFirstTopicAd);
85
70
  }
86
-
87
71
  if (postItems.length > 0 && config.enableMessageAds) {
88
72
  process(Array.from(postItems), 'message', config.messageIntervalPosts, config.showFirstMessageAd);
89
73
  }
@@ -94,7 +78,6 @@
94
78
  items.forEach((item, index) => {
95
79
  const pos = index + 1;
96
80
  const shouldHaveAd = (pos === 1 && showFirst) || (pos % int === 0);
97
-
98
81
  const next = item.nextElementSibling;
99
82
  if (shouldHaveAd && !(next && next.classList.contains(WRAP_CLASS))) {
100
83
  const pool = getPool();
@@ -115,26 +98,20 @@
115
98
  .then(data => {
116
99
  config = data;
117
100
  const pool = getPool();
118
-
119
101
  const setup = (raw, kind) => {
120
102
  if (!raw) return;
121
103
  raw.split(/[\s,]+/).filter(Boolean).forEach(id => {
122
- if (!document.querySelector(`[data-placeholder-id="${id}"]`)) {
123
- const d = document.createElement('div');
124
- d.className = WRAP_CLASS;
125
- d.setAttribute('data-kind', kind);
126
- d.setAttribute('data-placeholder-id', id);
127
- d.innerHTML = `<div id="ezoic-pub-ad-placeholder-${id}"></div>`;
128
- pool.appendChild(d);
129
- }
104
+ const d = document.createElement('div');
105
+ d.className = WRAP_CLASS;
106
+ d.setAttribute('data-kind', kind);
107
+ d.setAttribute('data-placeholder-id', id);
108
+ d.innerHTML = `<div id="ezoic-pub-ad-placeholder-${id}"></div>`;
109
+ pool.appendChild(d);
130
110
  });
131
111
  };
132
-
133
- // On initialise les 3 pools séparés
134
112
  setup(config.categoryPlaceholderIds, 'home');
135
113
  setup(config.placeholderIds, 'topic-list');
136
114
  setup(config.messagePlaceholderIds, 'message');
137
-
138
115
  redistribute();
139
116
 
140
117
  const observer = new MutationObserver(() => {
@@ -144,7 +121,7 @@
144
121
  });
145
122
  }
146
123
 
147
- window.addEventListener('action:ajaxify.end', () => setTimeout(redistribute, 800));
124
+ window.addEventListener('action:ajaxify.end', () => setTimeout(redistribute, 500));
148
125
 
149
126
  if (document.readyState === 'loading') {
150
127
  document.addEventListener('DOMContentLoaded', init);