nodebb-plugin-ezoic-infinite 1.8.54 → 1.8.56
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 +29 -10
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -136,15 +136,28 @@ const HEAD_PRECONNECTS = [
|
|
|
136
136
|
].join('\n');
|
|
137
137
|
|
|
138
138
|
const EZOIC_SCRIPTS = [
|
|
139
|
-
'<script data-cfasync="false" src="https://the.gatekeeperconsent.com/cmp.min.js"></script>',
|
|
140
|
-
'<script async src="//www.ezojs.com/ezoic/sa.min.js"></script>',
|
|
141
139
|
'<script>',
|
|
142
|
-
'
|
|
143
|
-
'
|
|
140
|
+
'(function(){',
|
|
141
|
+
' if (window.__nbbEzoicHeadLoaded) return;',
|
|
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
|
+
'})();',
|
|
144
159
|
'</script>',
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
].join('\n');
|
|
160
|
+
].join('\\n');
|
|
148
161
|
|
|
149
162
|
// ── Hooks ────────────────────────────────────────────────────────────────────
|
|
150
163
|
|
|
@@ -164,12 +177,18 @@ plugin.addAdminNavigation = async (header) => {
|
|
|
164
177
|
|
|
165
178
|
plugin.injectEzoicHead = async (data) => {
|
|
166
179
|
try {
|
|
180
|
+
const req = data.req;
|
|
181
|
+
|
|
182
|
+
// Très important : ne pas ré-injecter sur navigation AJAX (ajaxify)
|
|
183
|
+
const isXHR = !!(req && (req.xhr || req.headers?.['x-requested-with'] === 'XMLHttpRequest'));
|
|
184
|
+
if (isXHR) return data;
|
|
185
|
+
|
|
167
186
|
const settings = await getSettings();
|
|
168
|
-
const uid =
|
|
187
|
+
const uid = req?.uid ?? 0;
|
|
169
188
|
const excluded = await isUserExcluded(uid, settings.excludedGroups);
|
|
189
|
+
|
|
170
190
|
if (!excluded) {
|
|
171
|
-
|
|
172
|
-
data.templateData.customHTML = EZOIC_SCRIPTS + (data.templateData.customHTML || '');
|
|
191
|
+
data.templateData.customHTML = HEAD_PRECONNECTS + '\n' + EZOIC_SCRIPTS + '\n' + (data.templateData.customHTML || '');
|
|
173
192
|
}
|
|
174
193
|
} catch (_) {}
|
|
175
194
|
return data;
|