nodebb-plugin-ezoic-infinite 1.8.56 → 1.8.57
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 +26 -23
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -136,28 +136,23 @@ const HEAD_PRECONNECTS = [
|
|
|
136
136
|
].join('\n');
|
|
137
137
|
|
|
138
138
|
const EZOIC_SCRIPTS = [
|
|
139
|
+
HEAD_PRECONNECTS,
|
|
140
|
+
|
|
141
|
+
// CMP en premier
|
|
142
|
+
'<script data-cfasync="false" src="https://the.gatekeeperconsent.com/cmp.min.js"></script>',
|
|
143
|
+
|
|
144
|
+
// Standalone Ezoic
|
|
145
|
+
'<script async src="https://www.ezojs.com/ezoic/sa.min.js"></script>',
|
|
146
|
+
|
|
147
|
+
// cmd queue (OK en inline)
|
|
139
148
|
'<script>',
|
|
140
|
-
'
|
|
141
|
-
'
|
|
142
|
-
' window.__nbbEzoicHeadLoaded = true;',
|
|
143
|
-
'',
|
|
144
|
-
' window.ezstandalone = window.ezstandalone || {};',
|
|
145
|
-
' ezstandalone.cmd = ezstandalone.cmd || [];',
|
|
146
|
-
'',
|
|
147
|
-
' function addScript(src, attrs){',
|
|
148
|
-
' if (document.querySelector(\'script[src="\' + src + \'"]\')) return;',
|
|
149
|
-
' var s = document.createElement("script");',
|
|
150
|
-
' s.src = src;',
|
|
151
|
-
' if (attrs) { Object.keys(attrs).forEach(function(k){ s.setAttribute(k, attrs[k]); }); }',
|
|
152
|
-
' document.head.appendChild(s);',
|
|
153
|
-
' }',
|
|
154
|
-
'',
|
|
155
|
-
' addScript("https://the.gatekeeperconsent.com/cmp.min.js", {"data-cfasync":"false"});',
|
|
156
|
-
' addScript("https://www.ezojs.com/ezoic/sa.min.js", {"async":""});',
|
|
157
|
-
' addScript("https://ezoicanalytics.com/analytics.js");',
|
|
158
|
-
'})();',
|
|
149
|
+
'window.ezstandalone = window.ezstandalone || {};',
|
|
150
|
+
'ezstandalone.cmd = ezstandalone.cmd || [];',
|
|
159
151
|
'</script>',
|
|
160
|
-
|
|
152
|
+
|
|
153
|
+
// Analytics
|
|
154
|
+
'<script src="https://ezoicanalytics.com/analytics.js"></script>',
|
|
155
|
+
].join('\n');
|
|
161
156
|
|
|
162
157
|
// ── Hooks ────────────────────────────────────────────────────────────────────
|
|
163
158
|
|
|
@@ -179,8 +174,10 @@ plugin.injectEzoicHead = async (data) => {
|
|
|
179
174
|
try {
|
|
180
175
|
const req = data.req;
|
|
181
176
|
|
|
182
|
-
//
|
|
183
|
-
const isXHR =
|
|
177
|
+
// ✅ NodeBB = SPA (ajaxify). Ne pas ré-injecter les scripts Ezoic sur les requêtes XHR.
|
|
178
|
+
const isXHR =
|
|
179
|
+
!!(req && (req.xhr || String(req.headers?.['x-requested-with']).toLowerCase() === 'xmlhttprequest'));
|
|
180
|
+
|
|
184
181
|
if (isXHR) return data;
|
|
185
182
|
|
|
186
183
|
const settings = await getSettings();
|
|
@@ -188,9 +185,15 @@ plugin.injectEzoicHead = async (data) => {
|
|
|
188
185
|
const excluded = await isUserExcluded(uid, settings.excludedGroups);
|
|
189
186
|
|
|
190
187
|
if (!excluded) {
|
|
191
|
-
|
|
188
|
+
const existing = data.templateData.customHTML || '';
|
|
189
|
+
|
|
190
|
+
// ✅ Anti-doublon côté rendu (si un thème/plugin ajoute déjà sa.min.js)
|
|
191
|
+
if (!existing.includes('www.ezojs.com/ezoic/sa.min.js')) {
|
|
192
|
+
data.templateData.customHTML = EZOIC_SCRIPTS + existing;
|
|
193
|
+
}
|
|
192
194
|
}
|
|
193
195
|
} catch (_) {}
|
|
196
|
+
|
|
194
197
|
return data;
|
|
195
198
|
};
|
|
196
199
|
|