nodebb-plugin-ezoic-infinite 1.8.56 → 1.8.58
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 +23 -23
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -136,28 +136,24 @@ 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://cmp.gatekeeperconsent.com/min.js"></script>',
|
|
143
|
+
'<script data-cfasync="false" src="https://the.gatekeeperconsent.com/cmp.min.js"></script>',
|
|
144
|
+
|
|
145
|
+
// Standalone Ezoic
|
|
146
|
+
'<script async src="https://www.ezojs.com/ezoic/sa.min.js"></script>',
|
|
147
|
+
|
|
148
|
+
// cmd queue (OK en inline)
|
|
139
149
|
'<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
|
-
'})();',
|
|
150
|
+
'window.ezstandalone = window.ezstandalone || {};',
|
|
151
|
+
'ezstandalone.cmd = ezstandalone.cmd || [];',
|
|
159
152
|
'</script>',
|
|
160
|
-
|
|
153
|
+
|
|
154
|
+
// Analytics
|
|
155
|
+
'<script src="https://ezoicanalytics.com/analytics.js"></script>',
|
|
156
|
+
].join('\n');
|
|
161
157
|
|
|
162
158
|
// ── Hooks ────────────────────────────────────────────────────────────────────
|
|
163
159
|
|
|
@@ -179,8 +175,10 @@ plugin.injectEzoicHead = async (data) => {
|
|
|
179
175
|
try {
|
|
180
176
|
const req = data.req;
|
|
181
177
|
|
|
182
|
-
//
|
|
183
|
-
const isXHR =
|
|
178
|
+
// ✅ NodeBB = SPA (ajaxify). Ne pas ré-injecter les scripts Ezoic sur les requêtes XHR.
|
|
179
|
+
const isXHR =
|
|
180
|
+
!!(req && (req.xhr || String(req.headers?.['x-requested-with']).toLowerCase() === 'xmlhttprequest'));
|
|
181
|
+
|
|
184
182
|
if (isXHR) return data;
|
|
185
183
|
|
|
186
184
|
const settings = await getSettings();
|
|
@@ -188,9 +186,11 @@ plugin.injectEzoicHead = async (data) => {
|
|
|
188
186
|
const excluded = await isUserExcluded(uid, settings.excludedGroups);
|
|
189
187
|
|
|
190
188
|
if (!excluded) {
|
|
191
|
-
|
|
189
|
+
const existing = data.templateData.customHTML || '';
|
|
190
|
+
data.templateData.customHTML = EZOIC_SCRIPTS + existing;
|
|
192
191
|
}
|
|
193
192
|
} catch (_) {}
|
|
193
|
+
|
|
194
194
|
return data;
|
|
195
195
|
};
|
|
196
196
|
|