nodebb-plugin-ezoic-infinite 1.6.93 → 1.6.94
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 +49 -70
- package/public/style.css +71 -14
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -5,63 +5,12 @@
|
|
|
5
5
|
window.ezInfiniteInjected = true;
|
|
6
6
|
|
|
7
7
|
const WRAP_CLASS = 'nodebb-ezoic-wrap';
|
|
8
|
-
const POOL_ID = 'nodebb-ezoic-placeholder-pool';
|
|
9
|
-
|
|
10
8
|
let config = null;
|
|
11
9
|
let isInternalChange = false;
|
|
12
|
-
|
|
13
|
-
// Registre global pour ne JAMAIS redéfinir un ID déjà vu par Ezoic
|
|
14
|
-
window.ezoicDefinedIds = window.ezoicDefinedIds || new Set();
|
|
15
|
-
|
|
16
|
-
let pendingIds = new Set();
|
|
17
10
|
let triggerTimer = null;
|
|
18
11
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!p) {
|
|
22
|
-
p = document.createElement('div');
|
|
23
|
-
p.id = POOL_ID;
|
|
24
|
-
p.style.display = 'none';
|
|
25
|
-
document.body.appendChild(p);
|
|
26
|
-
}
|
|
27
|
-
return p;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function triggerEzoic() {
|
|
31
|
-
if (typeof window.ezstandalone === 'undefined' || pendingIds.size === 0) return;
|
|
32
|
-
|
|
33
|
-
window.ezstandalone.cmd.push(function() {
|
|
34
|
-
const allPending = Array.from(pendingIds);
|
|
35
|
-
pendingIds.clear();
|
|
36
|
-
|
|
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);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function callEzoic(id) {
|
|
57
|
-
const pid = parseInt(id, 10);
|
|
58
|
-
if (isNaN(pid)) return;
|
|
59
|
-
pendingIds.add(pid);
|
|
60
|
-
|
|
61
|
-
clearTimeout(triggerTimer);
|
|
62
|
-
triggerTimer = setTimeout(triggerEzoic, 150);
|
|
63
|
-
}
|
|
64
|
-
|
|
12
|
+
// On récupère les IDs déjà présents dans la page (générés par ton intégration de base)
|
|
13
|
+
// pour éviter de tenter de les redéfinir.
|
|
65
14
|
function redistribute() {
|
|
66
15
|
if (!config || config.excluded) return;
|
|
67
16
|
|
|
@@ -84,45 +33,80 @@
|
|
|
84
33
|
|
|
85
34
|
function process(items, kind, interval, showFirst) {
|
|
86
35
|
const int = parseInt(interval, 10) || 10;
|
|
36
|
+
const pool = document.getElementById('nodebb-ezoic-placeholder-pool');
|
|
37
|
+
if (!pool) return;
|
|
38
|
+
|
|
87
39
|
items.forEach((item, index) => {
|
|
88
40
|
const pos = index + 1;
|
|
89
41
|
const shouldHaveAd = (pos === 1 && showFirst) || (pos % int === 0);
|
|
90
42
|
const next = item.nextElementSibling;
|
|
91
43
|
|
|
44
|
+
// Si on doit mettre une pub et qu'il n'y en a pas déjà une après cet élément
|
|
92
45
|
if (shouldHaveAd && !(next && next.classList.contains(WRAP_CLASS))) {
|
|
93
|
-
const pool = getPool();
|
|
94
46
|
const available = pool.querySelector(`.${WRAP_CLASS}[data-kind="${kind}"]`);
|
|
95
47
|
|
|
96
48
|
if (available) {
|
|
97
49
|
isInternalChange = true;
|
|
98
50
|
item.parentNode.insertBefore(available, item.nextSibling);
|
|
99
|
-
|
|
51
|
+
|
|
52
|
+
const placeholderId = available.getAttribute('data-placeholder-id');
|
|
53
|
+
refreshAd(placeholderId);
|
|
54
|
+
|
|
100
55
|
setTimeout(() => { isInternalChange = false; }, 50);
|
|
101
56
|
}
|
|
102
57
|
}
|
|
103
58
|
});
|
|
104
59
|
}
|
|
105
60
|
|
|
61
|
+
function refreshAd(id) {
|
|
62
|
+
if (typeof window.ezstandalone === 'undefined') return;
|
|
63
|
+
|
|
64
|
+
clearTimeout(triggerTimer);
|
|
65
|
+
triggerTimer = setTimeout(() => {
|
|
66
|
+
window.ezstandalone.cmd.push(function() {
|
|
67
|
+
// Au lieu de define(), on utilise simplement showAds()
|
|
68
|
+
// Ezoic va détecter que le div avec cet ID a bougé et va le remplir.
|
|
69
|
+
try {
|
|
70
|
+
// On force l'affichage de cet ID spécifique
|
|
71
|
+
window.ezstandalone.showAds(parseInt(id, 10));
|
|
72
|
+
console.debug('[Ezoic] Displaying ID:', id);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.error('[Ezoic] Error showing ID:', id, e);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}, 100);
|
|
78
|
+
}
|
|
79
|
+
|
|
106
80
|
function init() {
|
|
107
81
|
fetch('/api/plugins/ezoic-infinite/config')
|
|
108
82
|
.then(r => r.json())
|
|
109
83
|
.then(data => {
|
|
110
84
|
config = data;
|
|
111
|
-
|
|
85
|
+
|
|
86
|
+
// On crée un pool CACHÉ qui contient tous les placeholders déclarés dans l'admin
|
|
87
|
+
let pool = document.getElementById('nodebb-ezoic-placeholder-pool');
|
|
88
|
+
if (!pool) {
|
|
89
|
+
pool = document.createElement('div');
|
|
90
|
+
pool.id = 'nodebb-ezoic-placeholder-pool';
|
|
91
|
+
pool.style.display = 'none';
|
|
92
|
+
document.body.appendChild(pool);
|
|
93
|
+
}
|
|
94
|
+
|
|
112
95
|
const setup = (raw, kind) => {
|
|
113
96
|
if (!raw) return;
|
|
114
97
|
raw.split(/[\s,]+/).filter(Boolean).forEach(id => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
pool.appendChild(
|
|
98
|
+
if (!document.getElementById(`ezoic-pub-ad-placeholder-${id}`)) {
|
|
99
|
+
const wrap = document.createElement('div');
|
|
100
|
+
wrap.className = WRAP_CLASS;
|
|
101
|
+
wrap.setAttribute('data-kind', kind);
|
|
102
|
+
wrap.setAttribute('data-placeholder-id', id);
|
|
103
|
+
// Structure exacte attendue par Ezoic
|
|
104
|
+
wrap.innerHTML = `<div id="ezoic-pub-ad-placeholder-${id}"></div>`;
|
|
105
|
+
pool.appendChild(wrap);
|
|
123
106
|
}
|
|
124
107
|
});
|
|
125
108
|
};
|
|
109
|
+
|
|
126
110
|
setup(config.categoryPlaceholderIds, 'home');
|
|
127
111
|
setup(config.placeholderIds, 'topic-list');
|
|
128
112
|
setup(config.messagePlaceholderIds, 'message');
|
|
@@ -136,12 +120,7 @@
|
|
|
136
120
|
});
|
|
137
121
|
}
|
|
138
122
|
|
|
139
|
-
|
|
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
|
|
143
|
-
setTimeout(redistribute, 500);
|
|
144
|
-
});
|
|
123
|
+
window.addEventListener('action:ajaxify.end', () => setTimeout(redistribute, 500));
|
|
145
124
|
|
|
146
125
|
if (document.readyState === 'loading') {
|
|
147
126
|
document.addEventListener('DOMContentLoaded', init);
|
package/public/style.css
CHANGED
|
@@ -1,34 +1,91 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* ============================================================
|
|
2
|
+
CONTAINER GLOBAL DES PUBS
|
|
3
|
+
============================================================ */
|
|
2
4
|
.nodebb-ezoic-wrap {
|
|
3
5
|
display: block !important;
|
|
4
6
|
width: 100% !important;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
min-height: 250px; /* Réserve l'espace pour éviter le saut de contenu (CLS) */
|
|
8
|
+
margin: 30px 0 !important;
|
|
9
|
+
padding: 0;
|
|
10
|
+
clear: both !important;
|
|
8
11
|
text-align: center;
|
|
12
|
+
position: relative;
|
|
13
|
+
overflow: hidden;
|
|
9
14
|
}
|
|
10
15
|
|
|
11
|
-
/*
|
|
16
|
+
/* On s'assure que le contenu Ezoic à l'intérieur est centré */
|
|
17
|
+
.nodebb-ezoic-wrap > div {
|
|
18
|
+
margin: 0 auto !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* ============================================================
|
|
22
|
+
1. PAGE D'ACCUEIL (Liste des catégories)
|
|
23
|
+
============================================================ */
|
|
12
24
|
[component="categories/category"] + .nodebb-ezoic-wrap,
|
|
13
25
|
.category-item + .nodebb-ezoic-wrap {
|
|
14
26
|
margin: 40px 0 !important;
|
|
15
27
|
border-top: 1px solid rgba(0,0,0,0.05);
|
|
28
|
+
padding-top: 25px;
|
|
29
|
+
background: transparent;
|
|
16
30
|
}
|
|
17
31
|
|
|
18
|
-
/*
|
|
32
|
+
/* ============================================================
|
|
33
|
+
2. PAGE CATÉGORIE (Liste des Topics / Sujets)
|
|
34
|
+
============================================================ */
|
|
35
|
+
/* Important : NodeBB Harmony utilise des <li> pour les topics.
|
|
36
|
+
On s'assure que notre wrap ne casse pas la structure de liste
|
|
37
|
+
mais s'affiche comme un bloc complet. */
|
|
19
38
|
li[component="category/topic"] + .nodebb-ezoic-wrap {
|
|
20
39
|
list-style: none !important;
|
|
21
|
-
|
|
40
|
+
margin: 0 !important;
|
|
41
|
+
padding: 20px 0 !important;
|
|
22
42
|
border-bottom: 1px solid rgba(0,0,0,0.05);
|
|
43
|
+
display: block !important;
|
|
44
|
+
float: none !important;
|
|
45
|
+
width: 100%;
|
|
23
46
|
}
|
|
24
47
|
|
|
25
|
-
/*
|
|
48
|
+
/* ============================================================
|
|
49
|
+
3. PAGE DES POSTS (Messages à l'intérieur d'un topic)
|
|
50
|
+
============================================================ */
|
|
26
51
|
[component="post"] + .nodebb-ezoic-wrap {
|
|
27
|
-
margin:
|
|
28
|
-
padding:
|
|
29
|
-
background: rgba(0,0,0,0.
|
|
52
|
+
margin: 45px 0 !important;
|
|
53
|
+
padding: 25px;
|
|
54
|
+
background: rgba(0,0,0,0.02); /* Léger fond pour distinguer le message pub */
|
|
55
|
+
border-radius: 12px;
|
|
56
|
+
border: 1px inset rgba(0,0,0,0.03);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* ============================================================
|
|
60
|
+
CORRECTIFS ANTI "PILE-UP" & AFFICHAGE
|
|
61
|
+
============================================================ */
|
|
62
|
+
|
|
63
|
+
/* Évite que les pubs ne soient invisibles si Ezoic ne charge rien immédiatement */
|
|
64
|
+
.nodebb-ezoic-wrap:empty {
|
|
65
|
+
min-height: 1px;
|
|
66
|
+
height: 1px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Neutralise les marges forcées par Ezoic qui pourraient décaler le layout */
|
|
70
|
+
.ezoic-ad {
|
|
71
|
+
margin: 10px auto !important;
|
|
72
|
+
display: block !important;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Mobile : Réduction des marges pour ne pas perdre trop de place */
|
|
76
|
+
@media (max-width: 767px) {
|
|
77
|
+
.nodebb-ezoic-wrap {
|
|
78
|
+
margin: 20px 0 !important;
|
|
79
|
+
min-height: 100px;
|
|
80
|
+
}
|
|
81
|
+
[component="post"] + .nodebb-ezoic-wrap {
|
|
82
|
+
padding: 10px;
|
|
83
|
+
margin: 25px 0 !important;
|
|
84
|
+
}
|
|
30
85
|
}
|
|
31
86
|
|
|
32
|
-
/*
|
|
33
|
-
.nodebb-ezoic-wrap
|
|
34
|
-
.ezoic-
|
|
87
|
+
/* Empêche les sauts de ligne bizarres dans les listes Harmony */
|
|
88
|
+
.categories > li.nodebb-ezoic-wrap,
|
|
89
|
+
.category > li.nodebb-ezoic-wrap {
|
|
90
|
+
float: none !important;
|
|
91
|
+
}
|