nodebb-plugin-ezoic-infinite 1.7.39 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/client.js +35 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.7.39",
3
+ "version": "1.7.40",
4
4
  "description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/public/client.js CHANGED
@@ -32,10 +32,10 @@
32
32
  *
33
33
  * v34 moveDistantWrap — voir v38.
34
34
  *
35
- * v43 Seuil de recyclage abaissé à -vh (hors viewport visible).
36
- * recycleAndMove appelle unobserve(ph) avant de déplacer le wrap,
37
- * ce qui neutralise l'IO sur ce nœud — plus de risque de showAds
38
- * parasite après recyclage. Plus de wraps éligibles = moins de pool sec.
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