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 +1 -1
- package/public/client.js +28 -23
- package/public/style.css +15 -10
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
36
|
-
|
|
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
|
-
}
|
|
42
|
+
});
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
function redistribute() {
|
|
42
46
|
if (!config || config.excluded) return;
|
|
43
47
|
|
|
44
|
-
// Sélecteurs
|
|
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
|
-
|
|
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
|
-
|
|
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 %
|
|
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:
|
|
6
|
-
min-height:
|
|
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
|
-
/*
|
|
11
|
-
|
|
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
|
-
/*
|
|
16
|
-
|
|
17
|
-
|
|
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
|
}
|