nodebb-plugin-ezoic-infinite 1.5.11 → 1.5.13
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 +8 -1
- package/package.json +1 -1
- package/public/client.js +10 -4
package/library.js
CHANGED
|
@@ -70,6 +70,12 @@ async function isUserExcluded(uid, excludedGroups) {
|
|
|
70
70
|
if (uid === undefined || uid === null || !excludedGroups.length) return false;
|
|
71
71
|
|
|
72
72
|
const excludedSet = new Set(excludedGroups.map(g => String(g).toLowerCase()));
|
|
73
|
+
// Guests: NodeBB often represents them as uid=0 and they may not have groups in the database.
|
|
74
|
+
if (uid === 0) {
|
|
75
|
+
return excludedSet.has('guests') || excludedSet.has('guest');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
73
79
|
const userGroups = await groups.getUserGroups([uid]);
|
|
74
80
|
return (userGroups[0] || []).some(g => {
|
|
75
81
|
const name = (g && g.name) ? g.name : g;
|
|
@@ -114,7 +120,8 @@ plugin.init = async ({ router, middleware }) => {
|
|
|
114
120
|
|
|
115
121
|
router.get('/api/plugins/ezoic-infinite/config', async (req, res) => {
|
|
116
122
|
const settings = await getSettings();
|
|
117
|
-
const
|
|
123
|
+
const uid = (typeof req.uid === 'number' ? req.uid : (req.user && typeof req.user.uid === 'number' ? req.user.uid : (res.locals && typeof res.locals.uid === 'number' ? res.locals.uid : 0)));
|
|
124
|
+
const excluded = await isUserExcluded(uid, settings.excludedGroups);
|
|
118
125
|
|
|
119
126
|
res.json({
|
|
120
127
|
excluded,
|
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -560,8 +560,11 @@
|
|
|
560
560
|
ensurePreloadObserver();
|
|
561
561
|
ensureDomObserver();
|
|
562
562
|
|
|
563
|
-
// Ultra-fast above-the-fold first
|
|
564
|
-
|
|
563
|
+
// Ultra-fast above-the-fold first (respect excluded groups)
|
|
564
|
+
fetchConfigOnce().then((cfg) => {
|
|
565
|
+
if (!cfg || cfg.excluded) return;
|
|
566
|
+
insertHeroAdEarly().catch(() => {});
|
|
567
|
+
}).catch(() => {});
|
|
565
568
|
|
|
566
569
|
// Then normal insertion
|
|
567
570
|
scheduleRun();
|
|
@@ -597,8 +600,11 @@
|
|
|
597
600
|
bindNodeBB();
|
|
598
601
|
bindScroll();
|
|
599
602
|
|
|
600
|
-
// First paint: try hero + run
|
|
603
|
+
// First paint: try hero + run (respect excluded groups)
|
|
601
604
|
EZOIC_BLOCKED = false;
|
|
602
|
-
|
|
605
|
+
fetchConfigOnce().then((cfg) => {
|
|
606
|
+
if (!cfg || cfg.excluded) return;
|
|
607
|
+
insertHeroAdEarly().catch(() => {});
|
|
608
|
+
}).catch(() => {});
|
|
603
609
|
scheduleRun();
|
|
604
610
|
})();
|