nodebb-plugin-ezoic-infinite 1.7.37 → 1.7.38

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 (3) hide show
  1. package/library.js +14 -21
  2. package/package.json +1 -1
  3. package/plugin.json +2 -2
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 à injecter dans le <head> ────────────────────────────────
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 EZOIC_HEAD_HTML = `<script data-cfasync="false" src="https://cmp.gatekeeperconsent.com/min.js"></script>
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,27 @@ 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> pour les utilisateurs non-exclus.
107
- * Hook : filter:middleware.renderHeader
108
- * NodeBB appelle ce hook avant de rendre le header — templateData.headHTML
109
- * est concaténé dans le <head> de chaque page.
95
+ * Injecte les scripts Ezoic via res.locals.postHeader.
96
+ *
97
+ * NodeBB v4 insère res.locals.postHeader directement après le header rendu
98
+ * (src/middleware/render.js) : `results.header + (res.locals.postHeader || '')`
99
+ * C'est le point d'injection natif pour du HTML arbitraire post-<head>.
100
+ *
101
+ * Le hook filter:middleware.buildHeader expose data.locals = res.locals,
102
+ * et est appelé avant le rendu de chaque page non-API.
110
103
  */
111
- plugin.injectEzoicHead = async (data) => {
104
+ plugin.injectEzoicScripts = async (data) => {
112
105
  try {
113
106
  const settings = await getSettings();
114
- const uid = data.templateData?.uid ?? data.req?.uid ?? 0;
107
+ const uid = data.req?.uid ?? 0;
115
108
  const excluded = await isUserExcluded(uid, settings.excludedGroups);
116
109
  if (!excluded) {
117
- data.templateData.headHTML = (data.templateData.headHTML || '') + EZOIC_HEAD_HTML;
110
+ data.locals.postHeader = (data.locals.postHeader || '') + EZOIC_SCRIPTS;
118
111
  }
119
112
  } catch (_) {}
120
113
  return data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.7.37",
3
+ "version": "1.7.38",
4
4
  "description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -17,8 +17,8 @@
17
17
  "method": "onSettingsSet"
18
18
  },
19
19
  {
20
- "hook": "filter:middleware.renderHeader",
21
- "method": "injectEzoicHead"
20
+ "hook": "filter:middleware.buildHeader",
21
+ "method": "injectEzoicScripts"
22
22
  }
23
23
  ],
24
24
  "staticDirs": {