nodebb-plugin-ezoic-infinite 1.8.90 → 1.8.91
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/package.json +1 -1
- package/public/client.js +42 -11
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -886,25 +886,56 @@
|
|
|
886
886
|
|
|
887
887
|
// Retry boot: sa.min.js async + Cloudflare Rocket Loader + NodeBB SPA
|
|
888
888
|
// can cause client.js to boot before DOM/Ezoic are ready.
|
|
889
|
-
//
|
|
890
|
-
//
|
|
889
|
+
//
|
|
890
|
+
// Two reload cases:
|
|
891
|
+
// 1. sa.min.js never injected (Rocket Loader stripped it) — reload immediately.
|
|
892
|
+
// 2. Cold-start crash: first visit with no Ezoic cookies causes sa.min.js to set
|
|
893
|
+
// loadingStatus='LOADING' but never reach 'complete' (_ezaq.ab_test_id undefined
|
|
894
|
+
// in ez-standalone.js → onStandaloneLoadEvent crash). After ~6s, remove and reload
|
|
895
|
+
// sa.min.js; Ezoic's partial first-run state may let the second run succeed.
|
|
896
|
+
// Once recovered, re-enqueue all mounted placeholders so showAds() fires.
|
|
891
897
|
let _retries = 0;
|
|
892
898
|
let _scriptReloaded = false;
|
|
899
|
+
let _postReloadShown = false;
|
|
893
900
|
function retryBoot() {
|
|
894
|
-
if (_retries >= 12
|
|
901
|
+
if (_retries >= 12) return;
|
|
895
902
|
_retries++;
|
|
896
903
|
patchShowAds();
|
|
897
904
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
//
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
const
|
|
905
|
-
|
|
905
|
+
const ez = window.ezstandalone;
|
|
906
|
+
const status = ez?.loadingStatus;
|
|
907
|
+
|
|
908
|
+
// After reload: once Ezoic reaches 'complete', re-call showAds for all mounted placeholders
|
|
909
|
+
if (_scriptReloaded && !_postReloadShown && status === 'complete') {
|
|
910
|
+
_postReloadShown = true;
|
|
911
|
+
for (const id of S.mountedIds) { try { enqueueShow(id); } catch (_) {} }
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
// Normal exit: placeholders mounted, no reload triggered (healthy load)
|
|
916
|
+
if (S.mountedIds.size > 0 && !_scriptReloaded) return;
|
|
917
|
+
// Exit once reload is done and re-show has been triggered
|
|
918
|
+
if (_scriptReloaded && _postReloadShown) return;
|
|
919
|
+
|
|
920
|
+
if (!_scriptReloaded) {
|
|
921
|
+
// Case 1: sa.min.js never injected (Rocket Loader stripped it, etc.)
|
|
922
|
+
const neverInjected = !status && !document.querySelector('script[src*="sa.min.js"]') && _retries <= 3;
|
|
923
|
+
// Case 2: cold-start crash — loadingStatus stuck before 'complete' after enough wait.
|
|
924
|
+
// Do NOT reload when status==='complete' (post-defineScript-failure would re-trigger).
|
|
925
|
+
const anyFilled = !!document.querySelector(`.${WRAP_CLASS} ${FILL_SEL}`);
|
|
926
|
+
const crashed = _retries >= 8 && !anyFilled && status && status !== 'complete';
|
|
927
|
+
if (neverInjected || crashed) {
|
|
906
928
|
_scriptReloaded = true;
|
|
907
929
|
try {
|
|
930
|
+
if (crashed) {
|
|
931
|
+
// Remove the broken script before re-adding to avoid a duplicate
|
|
932
|
+
const old = document.querySelector('script[src*="sa.min.js"]');
|
|
933
|
+
if (old) old.remove();
|
|
934
|
+
// Reset ezstandalone to initial state, preserving queued cmd items
|
|
935
|
+
const savedCmd = Array.isArray(ez?.cmd) ? [...ez.cmd] : [];
|
|
936
|
+
window.ezstandalone = { cmd: savedCmd };
|
|
937
|
+
window.__nbbEzPatched = false;
|
|
938
|
+
}
|
|
908
939
|
const s = document.createElement('script');
|
|
909
940
|
s.setAttribute('data-cfasync', 'false');
|
|
910
941
|
s.src = '//www.ezojs.com/ezoic/sa.min.js';
|