nodebb-plugin-ezoic-infinite 1.6.92 → 1.6.93
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 +1 -1
- package/public/client.js +25 -33
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
let config = null;
|
|
11
11
|
let isInternalChange = false;
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
// Registre global pour ne JAMAIS redéfinir un ID déjà vu par Ezoic
|
|
14
|
+
window.ezoicDefinedIds = window.ezoicDefinedIds || new Set();
|
|
15
|
+
|
|
13
16
|
let pendingIds = new Set();
|
|
14
17
|
let triggerTimer = null;
|
|
15
18
|
|
|
@@ -28,24 +31,25 @@
|
|
|
28
31
|
if (typeof window.ezstandalone === 'undefined' || pendingIds.size === 0) return;
|
|
29
32
|
|
|
30
33
|
window.ezstandalone.cmd.push(function() {
|
|
31
|
-
const
|
|
34
|
+
const allPending = Array.from(pendingIds);
|
|
32
35
|
pendingIds.clear();
|
|
33
36
|
|
|
34
|
-
//
|
|
35
|
-
window.
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
window.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
// Filtrer pour ne garder que les IDs JAMAIS définis auparavant
|
|
38
|
+
const newIdsToDefine = allPending.filter(id => !window.ezoicDefinedIds.has(id));
|
|
39
|
+
|
|
40
|
+
if (newIdsToDefine.length > 0) {
|
|
41
|
+
window.ezstandalone.define(newIdsToDefine);
|
|
42
|
+
newIdsToDefine.forEach(id => window.ezoicDefinedIds.add(id));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// La doc dit : showAds(id1, id2) pour le nouveau contenu
|
|
46
|
+
// On appelle showAds sur tous les IDs qu'on vient d'injecter,
|
|
47
|
+
// qu'ils soient nouveaux ou recyclés.
|
|
48
|
+
try {
|
|
49
|
+
window.ezstandalone.showAds.apply(null, allPending);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.warn('[Ezoic] showAds failed', e);
|
|
45
52
|
}
|
|
46
|
-
|
|
47
|
-
// On garde trace pour le nettoyage futur
|
|
48
|
-
idsToProcess.forEach(id => activeIdsOnPage.add(id));
|
|
49
53
|
});
|
|
50
54
|
}
|
|
51
55
|
|
|
@@ -54,22 +58,8 @@
|
|
|
54
58
|
if (isNaN(pid)) return;
|
|
55
59
|
pendingIds.add(pid);
|
|
56
60
|
|
|
57
|
-
// On attend un peu pour grouper si plusieurs pubs arrivent en même temps
|
|
58
61
|
clearTimeout(triggerTimer);
|
|
59
|
-
triggerTimer = setTimeout(triggerEzoic,
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// "Changing Pages" : Nettoyage complet lors de la navigation NodeBB
|
|
63
|
-
function onPageChangeStart() {
|
|
64
|
-
if (typeof window.ezstandalone !== 'undefined') {
|
|
65
|
-
window.ezstandalone.cmd.push(function() {
|
|
66
|
-
// On nettoie tout avant de charger la nouvelle page
|
|
67
|
-
if (typeof window.ezstandalone.destroyAll === 'function') {
|
|
68
|
-
window.ezstandalone.destroyAll();
|
|
69
|
-
}
|
|
70
|
-
activeIdsOnPage.clear();
|
|
71
|
-
});
|
|
72
|
-
}
|
|
62
|
+
triggerTimer = setTimeout(triggerEzoic, 150);
|
|
73
63
|
}
|
|
74
64
|
|
|
75
65
|
function redistribute() {
|
|
@@ -122,6 +112,7 @@
|
|
|
122
112
|
const setup = (raw, kind) => {
|
|
123
113
|
if (!raw) return;
|
|
124
114
|
raw.split(/[\s,]+/).filter(Boolean).forEach(id => {
|
|
115
|
+
// Créer le placeholder dans le pool s'il n'existe pas encore physiquement
|
|
125
116
|
if (!pool.querySelector(`[data-placeholder-id="${id}"]`)) {
|
|
126
117
|
const d = document.createElement('div');
|
|
127
118
|
d.className = WRAP_CLASS;
|
|
@@ -145,9 +136,10 @@
|
|
|
145
136
|
});
|
|
146
137
|
}
|
|
147
138
|
|
|
148
|
-
//
|
|
149
|
-
window.addEventListener('action:ajaxify.start', onPageChangeStart);
|
|
139
|
+
// Navigation NodeBB (Ajaxify)
|
|
150
140
|
window.addEventListener('action:ajaxify.end', () => {
|
|
141
|
+
// On ne détruit RIEN au changement de page pour éviter les erreurs "already defined"
|
|
142
|
+
// On se contente de ré-injecter les placeholders du pool
|
|
151
143
|
setTimeout(redistribute, 500);
|
|
152
144
|
});
|
|
153
145
|
|