nodebb-plugin-ezoic-infinite 1.7.37 → 1.7.39
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/library.js +14 -20
- package/package.json +1 -1
- package/plugin.json +9 -29
package/library.js
CHANGED
|
@@ -50,17 +50,14 @@ async function getSettings() {
|
|
|
50
50
|
showFirstTopicAd: parseBool(s.showFirstTopicAd, false),
|
|
51
51
|
placeholderIds: (s.placeholderIds || '').trim(),
|
|
52
52
|
intervalPosts: Math.max(1, parseInt(s.intervalPosts, 10) || 6),
|
|
53
|
-
|
|
54
53
|
enableCategoryAds: parseBool(s.enableCategoryAds, false),
|
|
55
54
|
showFirstCategoryAd: parseBool(s.showFirstCategoryAd, false),
|
|
56
55
|
categoryPlaceholderIds: (s.categoryPlaceholderIds || '').trim(),
|
|
57
56
|
intervalCategories: Math.max(1, parseInt(s.intervalCategories, 10) || 4),
|
|
58
|
-
|
|
59
57
|
enableMessageAds: parseBool(s.enableMessageAds, false),
|
|
60
58
|
showFirstMessageAd: parseBool(s.showFirstMessageAd, false),
|
|
61
59
|
messagePlaceholderIds: (s.messagePlaceholderIds || '').trim(),
|
|
62
60
|
messageIntervalPosts: Math.max(1, parseInt(s.messageIntervalPosts, 10) || 3),
|
|
63
|
-
|
|
64
61
|
excludedGroups: normalizeExcludedGroups(s.excludedGroups),
|
|
65
62
|
};
|
|
66
63
|
return _settingsCache;
|
|
@@ -72,13 +69,9 @@ async function isUserExcluded(uid, excludedGroups) {
|
|
|
72
69
|
return (userGroups[0] || []).some(g => excludedGroups.includes(g.name));
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
// ── Scripts Ezoic
|
|
76
|
-
//
|
|
77
|
-
// Injectés uniquement pour les utilisateurs non-exclus.
|
|
78
|
-
// Recommandation Ezoic : charger ces scripts en <head> plutôt qu'en widget
|
|
79
|
-
// pour garantir le chargement avant le contenu de la page.
|
|
72
|
+
// ── Scripts Ezoic ──────────────────────────────────────────────────────────
|
|
80
73
|
|
|
81
|
-
const
|
|
74
|
+
const EZOIC_SCRIPTS = `<script data-cfasync="false" src="https://cmp.gatekeeperconsent.com/min.js"></script>
|
|
82
75
|
<script data-cfasync="false" src="https://the.gatekeeperconsent.com/cmp.min.js"></script>
|
|
83
76
|
<script async src="//www.ezojs.com/ezoic/sa.min.js"></script>
|
|
84
77
|
<script>
|
|
@@ -94,27 +87,28 @@ plugin.onSettingsSet = function (data) {
|
|
|
94
87
|
|
|
95
88
|
plugin.addAdminNavigation = async (header) => {
|
|
96
89
|
header.plugins = header.plugins || [];
|
|
97
|
-
header.plugins.push({
|
|
98
|
-
route: '/plugins/ezoic-infinite',
|
|
99
|
-
icon: 'fa-ad',
|
|
100
|
-
name: 'Ezoic Infinite Ads',
|
|
101
|
-
});
|
|
90
|
+
header.plugins.push({ route: '/plugins/ezoic-infinite', icon: 'fa-ad', name: 'Ezoic Infinite Ads' });
|
|
102
91
|
return header;
|
|
103
92
|
};
|
|
104
93
|
|
|
105
94
|
/**
|
|
106
|
-
* Injecte les scripts Ezoic dans le <head>
|
|
107
|
-
*
|
|
108
|
-
* NodeBB
|
|
109
|
-
*
|
|
95
|
+
* Injecte les scripts Ezoic dans le <head> via templateData.customHTML.
|
|
96
|
+
*
|
|
97
|
+
* NodeBB v4 / thème Harmony : header.tpl contient {{customHTML}} dans le <head>
|
|
98
|
+
* (render.js ligne 232 : templateValues.customHTML = meta.config.customHTML).
|
|
99
|
+
* Le hook filter:middleware.renderHeader reçoit templateData = headerFooterData
|
|
100
|
+
* et est rendu via req.app.renderAsync('header', hookReturn.templateData).
|
|
101
|
+
* On préfixe customHTML pour que nos scripts passent AVANT le customHTML admin,
|
|
102
|
+
* tout en préservant ce dernier.
|
|
110
103
|
*/
|
|
111
104
|
plugin.injectEzoicHead = async (data) => {
|
|
112
105
|
try {
|
|
113
106
|
const settings = await getSettings();
|
|
114
|
-
const uid = data.
|
|
107
|
+
const uid = data.req?.uid ?? 0;
|
|
115
108
|
const excluded = await isUserExcluded(uid, settings.excludedGroups);
|
|
116
109
|
if (!excluded) {
|
|
117
|
-
|
|
110
|
+
// Préfixer : nos scripts d'abord, puis le customHTML existant de l'admin
|
|
111
|
+
data.templateData.customHTML = EZOIC_SCRIPTS + (data.templateData.customHTML || '');
|
|
118
112
|
}
|
|
119
113
|
} catch (_) {}
|
|
120
114
|
return data;
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -4,34 +4,14 @@
|
|
|
4
4
|
"description": "Ezoic ads with infinite scroll using a pool of placeholder IDs",
|
|
5
5
|
"library": "./library.js",
|
|
6
6
|
"hooks": [
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
{
|
|
12
|
-
"hook": "filter:admin.header.build",
|
|
13
|
-
"method": "addAdminNavigation"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"hook": "action:settings.set",
|
|
17
|
-
"method": "onSettingsSet"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"hook": "filter:middleware.renderHeader",
|
|
21
|
-
"method": "injectEzoicHead"
|
|
22
|
-
}
|
|
7
|
+
{ "hook": "static:app.load", "method": "init" },
|
|
8
|
+
{ "hook": "filter:admin.header.build", "method": "addAdminNavigation" },
|
|
9
|
+
{ "hook": "action:settings.set", "method": "onSettingsSet" },
|
|
10
|
+
{ "hook": "filter:middleware.renderHeader","method": "injectEzoicHead" }
|
|
23
11
|
],
|
|
24
|
-
"staticDirs": {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
],
|
|
30
|
-
"scripts": [
|
|
31
|
-
"public/client.js"
|
|
32
|
-
],
|
|
33
|
-
"templates": "public/templates",
|
|
34
|
-
"css": [
|
|
35
|
-
"public/style.css"
|
|
36
|
-
]
|
|
12
|
+
"staticDirs": { "public": "public" },
|
|
13
|
+
"acpScripts": [ "public/admin.js" ],
|
|
14
|
+
"scripts": [ "public/client.js" ],
|
|
15
|
+
"templates": "public/templates",
|
|
16
|
+
"css": [ "public/style.css" ]
|
|
37
17
|
}
|