nodebb-plugin-ezoic-infinite 1.7.38 → 1.7.40
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 +10 -9
- package/package.json +1 -1
- package/plugin.json +9 -29
- package/public/client.js +35 -4
package/library.js
CHANGED
|
@@ -92,22 +92,23 @@ plugin.addAdminNavigation = async (header) => {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
* Injecte les scripts Ezoic via
|
|
95
|
+
* Injecte les scripts Ezoic dans le <head> via templateData.customHTML.
|
|
96
96
|
*
|
|
97
|
-
* NodeBB v4
|
|
98
|
-
* (
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
97
|
+
* NodeBB v4 / thème Harmony : header.tpl contient {{customHTML}} dans le <head>
|
|
98
|
+
* (render.js ligne 232 : templateValues.customHTML = meta.config.customHTML).
|
|
99
|
+
* Le hook filter:middleware.renderHeader reçoit templateData = headerFooterData
|
|
100
|
+
* et est rendu via req.app.renderAsync('header', hookReturn.templateData).
|
|
101
|
+
* On préfixe customHTML pour que nos scripts passent AVANT le customHTML admin,
|
|
102
|
+
* tout en préservant ce dernier.
|
|
103
103
|
*/
|
|
104
|
-
plugin.
|
|
104
|
+
plugin.injectEzoicHead = async (data) => {
|
|
105
105
|
try {
|
|
106
106
|
const settings = await getSettings();
|
|
107
107
|
const uid = data.req?.uid ?? 0;
|
|
108
108
|
const excluded = await isUserExcluded(uid, settings.excludedGroups);
|
|
109
109
|
if (!excluded) {
|
|
110
|
-
|
|
110
|
+
// Préfixer : nos scripts d'abord, puis le customHTML existant de l'admin
|
|
111
|
+
data.templateData.customHTML = EZOIC_SCRIPTS + (data.templateData.customHTML || '');
|
|
111
112
|
}
|
|
112
113
|
} catch (_) {}
|
|
113
114
|
return data;
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -4,34 +4,14 @@
|
|
|
4
4
|
"description": "Ezoic ads with infinite scroll using a pool of placeholder IDs",
|
|
5
5
|
"library": "./library.js",
|
|
6
6
|
"hooks": [
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
{
|
|
12
|
-
"hook": "filter:admin.header.build",
|
|
13
|
-
"method": "addAdminNavigation"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"hook": "action:settings.set",
|
|
17
|
-
"method": "onSettingsSet"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"hook": "filter:middleware.buildHeader",
|
|
21
|
-
"method": "injectEzoicScripts"
|
|
22
|
-
}
|
|
7
|
+
{ "hook": "static:app.load", "method": "init" },
|
|
8
|
+
{ "hook": "filter:admin.header.build", "method": "addAdminNavigation" },
|
|
9
|
+
{ "hook": "action:settings.set", "method": "onSettingsSet" },
|
|
10
|
+
{ "hook": "filter:middleware.renderHeader","method": "injectEzoicHead" }
|
|
23
11
|
],
|
|
24
|
-
"staticDirs": {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
],
|
|
30
|
-
"scripts": [
|
|
31
|
-
"public/client.js"
|
|
32
|
-
],
|
|
33
|
-
"templates": "public/templates",
|
|
34
|
-
"css": [
|
|
35
|
-
"public/style.css"
|
|
36
|
-
]
|
|
12
|
+
"staticDirs": { "public": "public" },
|
|
13
|
+
"acpScripts": [ "public/admin.js" ],
|
|
14
|
+
"scripts": [ "public/client.js" ],
|
|
15
|
+
"templates": "public/templates",
|
|
16
|
+
"css": [ "public/style.css" ]
|
|
37
17
|
}
|
package/public/client.js
CHANGED
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
*
|
|
33
33
|
* v34 moveDistantWrap — voir v38.
|
|
34
34
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
35
|
+
* v48 Reload page si utilisateur exclu après connexion (plus propre que
|
|
36
|
+
* retirer les scripts du DOM — le head sera re-rendu sans Ezoic).
|
|
37
|
+
*
|
|
38
|
+
* v43 Seuil de recyclage abaissé à -vh + unobserve avant recyclage.
|
|
39
39
|
*
|
|
40
40
|
* v42 Seuil -(IO_MARGIN + vh) (trop strict, peu de wraps éligibles).
|
|
41
41
|
*
|
|
@@ -818,6 +818,36 @@
|
|
|
818
818
|
} catch (_) {}
|
|
819
819
|
}
|
|
820
820
|
|
|
821
|
+
/**
|
|
822
|
+
* Retire les scripts Ezoic du DOM si l'utilisateur vient de se connecter
|
|
823
|
+
* et appartient à un groupe exclu.
|
|
824
|
+
*
|
|
825
|
+
* NodeBB ne recharge pas la page après login — les scripts injectés en <head>
|
|
826
|
+
* restent en DOM. On détecte la connexion en comparant l'uid avant/après
|
|
827
|
+
* chaque action:ajaxify.end, puis on vérifie /api/plugins/ezoic-infinite/config.
|
|
828
|
+
* Si excluded:true, on retire les 4 scripts Ezoic du DOM et on arrête le plugin.
|
|
829
|
+
*/
|
|
830
|
+
function bindLoginCheck() {
|
|
831
|
+
const $ = window.jQuery;
|
|
832
|
+
if (!$) return;
|
|
833
|
+
let prevUid = window.app?.user?.uid ?? 0;
|
|
834
|
+
|
|
835
|
+
$(window).on('action:ajaxify.end.nbbEzoicLogin', async () => {
|
|
836
|
+
const uid = window.app?.user?.uid ?? 0;
|
|
837
|
+
if (uid === prevUid || uid === 0) { prevUid = uid; return; }
|
|
838
|
+
prevUid = uid;
|
|
839
|
+
// L'utilisateur vient de se connecter — vérifier s'il est exclu
|
|
840
|
+
try {
|
|
841
|
+
const r = await fetch('/api/plugins/ezoic-infinite/config', { credentials: 'same-origin' });
|
|
842
|
+
if (!r.ok) return;
|
|
843
|
+
const cfg = await r.json();
|
|
844
|
+
if (!cfg.excluded) return;
|
|
845
|
+
// Exclu : recharger la page — le <head> sera re-rendu sans les scripts Ezoic
|
|
846
|
+
window.location.reload();
|
|
847
|
+
} catch (_) {}
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
|
|
821
851
|
function bindScroll() {
|
|
822
852
|
let ticking = false;
|
|
823
853
|
window.addEventListener('scroll', () => {
|
|
@@ -838,6 +868,7 @@
|
|
|
838
868
|
ensureDomObserver();
|
|
839
869
|
bindNodeBB();
|
|
840
870
|
bindScroll();
|
|
871
|
+
bindLoginCheck();
|
|
841
872
|
blockedUntil = 0;
|
|
842
873
|
requestBurst();
|
|
843
874
|
|