nodebb-plugin-ezoic-infinite 1.8.66 → 1.8.67
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 +13 -24
- package/package.json +1 -1
- package/public/client.js +262 -560
- package/public/style.css +1 -6
package/library.js
CHANGED
|
@@ -87,11 +87,8 @@ async function isUserExcluded(uid, excludedGroups) {
|
|
|
87
87
|
const value = (userGroups[0] || []).some(g => excludedSet.has(g.name));
|
|
88
88
|
|
|
89
89
|
_excludeCache.set(key, { value, at: Date.now() });
|
|
90
|
-
|
|
91
|
-
// Limit cache size to prevent unbounded growth
|
|
92
90
|
if (_excludeCache.size > 1000) {
|
|
93
|
-
|
|
94
|
-
_excludeCache.delete(oldest);
|
|
91
|
+
_excludeCache.delete(_excludeCache.keys().next().value);
|
|
95
92
|
}
|
|
96
93
|
|
|
97
94
|
return value;
|
|
@@ -124,7 +121,7 @@ function buildClientConfig(settings, excluded) {
|
|
|
124
121
|
}
|
|
125
122
|
|
|
126
123
|
function serializeInlineConfig(cfg) {
|
|
127
|
-
return `<script>window.__nbbEzoicCfg=${JSON.stringify(cfg).replace(/</g, '\\u003c')};</script>`;
|
|
124
|
+
return `<script data-cfasync="false">window.__nbbEzoicCfg=${JSON.stringify(cfg).replace(/</g, '\\u003c')};</script>`;
|
|
128
125
|
}
|
|
129
126
|
|
|
130
127
|
// ── Head injection ───────────────────────────────────────────────────────────
|
|
@@ -138,14 +135,13 @@ const HEAD_PRECONNECTS = [
|
|
|
138
135
|
'<link rel="dns-prefetch" href="https://securepubads.g.doubleclick.net">',
|
|
139
136
|
].join('\n');
|
|
140
137
|
|
|
138
|
+
// Match v50 exactly: CMP → sa.min.js, no stubs.
|
|
139
|
+
// sa.min.js defines _ezaq and ezstandalone itself.
|
|
140
|
+
// Placing stubs before or alongside sa.min.js changes Ezoic's init path
|
|
141
|
+
// and causes "Timed out waiting for loadingStatus" errors.
|
|
141
142
|
const EZOIC_SCRIPTS = [
|
|
142
143
|
'<script data-cfasync="false" src="https://cmp.gatekeeperconsent.com/min.js"></script>',
|
|
143
144
|
'<script data-cfasync="false" src="https://the.gatekeeperconsent.com/cmp.min.js"></script>',
|
|
144
|
-
'<script>',
|
|
145
|
-
'window._ezaq = window._ezaq || {};',
|
|
146
|
-
'window.ezstandalone = window.ezstandalone || {};',
|
|
147
|
-
'ezstandalone.cmd = ezstandalone.cmd || [];',
|
|
148
|
-
'</script>',
|
|
149
145
|
'<script async src="//www.ezojs.com/ezoic/sa.min.js"></script>',
|
|
150
146
|
'<script src="//ezoicanalytics.com/analytics.js"></script>',
|
|
151
147
|
].join('\n');
|
|
@@ -166,10 +162,6 @@ plugin.addAdminNavigation = async (header) => {
|
|
|
166
162
|
return header;
|
|
167
163
|
};
|
|
168
164
|
|
|
169
|
-
/**
|
|
170
|
-
* Inject Ezoic scripts into <head> via templateData.customHTML.
|
|
171
|
-
* NodeBB v4/Harmony: header.tpl has {{customHTML}} in <head>.
|
|
172
|
-
*/
|
|
173
165
|
plugin.injectEzoicHead = async (data) => {
|
|
174
166
|
try {
|
|
175
167
|
const settings = await getSettings();
|
|
@@ -177,17 +169,14 @@ plugin.injectEzoicHead = async (data) => {
|
|
|
177
169
|
const excluded = await isUserExcluded(uid, settings.excludedGroups);
|
|
178
170
|
|
|
179
171
|
if (excluded) {
|
|
180
|
-
// Even for excluded users, inject a minimal stub so that any script
|
|
181
|
-
// referencing ezstandalone doesn't throw a ReferenceError, plus
|
|
182
|
-
// the config with excluded=true so client.js bails early.
|
|
183
172
|
const cfg = buildClientConfig(settings, true);
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
'window.
|
|
188
|
-
'ezstandalone.
|
|
189
|
-
'
|
|
190
|
-
|
|
173
|
+
// Minimal stub for excluded users — prevents ReferenceError if other
|
|
174
|
+
// scripts reference _ezaq or ezstandalone
|
|
175
|
+
const stub = '<script>'
|
|
176
|
+
+ 'window._ezaq=window._ezaq||{};'
|
|
177
|
+
+ 'window.ezstandalone=window.ezstandalone||{};'
|
|
178
|
+
+ 'window.ezstandalone.cmd=window.ezstandalone.cmd||[];'
|
|
179
|
+
+ '</script>';
|
|
191
180
|
data.templateData.customHTML =
|
|
192
181
|
stub + '\n' +
|
|
193
182
|
serializeInlineConfig(cfg) +
|