nodebb-plugin-ezoic-infinite 1.7.38 → 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.
Files changed (3) hide show
  1. package/library.js +10 -9
  2. package/package.json +1 -1
  3. package/plugin.json +9 -29
package/library.js CHANGED
@@ -92,22 +92,23 @@ plugin.addAdminNavigation = async (header) => {
92
92
  };
93
93
 
94
94
  /**
95
- * Injecte les scripts Ezoic via res.locals.postHeader.
95
+ * Injecte les scripts Ezoic dans le <head> via templateData.customHTML.
96
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.
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.
103
103
  */
104
- plugin.injectEzoicScripts = async (data) => {
104
+ plugin.injectEzoicHead = async (data) => {
105
105
  try {
106
106
  const settings = await getSettings();
107
107
  const uid = data.req?.uid ?? 0;
108
108
  const excluded = await isUserExcluded(uid, settings.excludedGroups);
109
109
  if (!excluded) {
110
- data.locals.postHeader = (data.locals.postHeader || '') + EZOIC_SCRIPTS;
110
+ // Préfixer : nos scripts d'abord, puis le customHTML existant de l'admin
111
+ data.templateData.customHTML = EZOIC_SCRIPTS + (data.templateData.customHTML || '');
111
112
  }
112
113
  } catch (_) {}
113
114
  return data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.7.38",
3
+ "version": "1.7.39",
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
@@ -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
- "hook": "static:app.load",
9
- "method": "init"
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.buildHeader",
21
- "method": "injectEzoicScripts"
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
- "public": "public"
26
- },
27
- "acpScripts": [
28
- "public/admin.js"
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
  }