nodebb-plugin-ezoic-infinite 1.8.47 → 1.8.48
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 +12 -58
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -32,14 +32,12 @@
|
|
|
32
32
|
BLOCK_DURATION_MS: 1_500,
|
|
33
33
|
SHOW_TIMEOUT_MS: 7_000,
|
|
34
34
|
SHOW_RELEASE_MS: 700,
|
|
35
|
-
BATCH_FLUSH_MS: 80,
|
|
36
35
|
RECYCLE_DELAY_MS: 450,
|
|
37
36
|
};
|
|
38
37
|
|
|
39
38
|
const LIMITS = {
|
|
40
39
|
MAX_INSERTS_RUN: 6,
|
|
41
40
|
MAX_INFLIGHT: 4,
|
|
42
|
-
BATCH_SIZE: 3,
|
|
43
41
|
MAX_BURST_STEPS: 8,
|
|
44
42
|
BURST_WINDOW_MS: 2_000,
|
|
45
43
|
};
|
|
@@ -698,9 +696,9 @@
|
|
|
698
696
|
|
|
699
697
|
// ── Patch Ezoic showAds ────────────────────────────────────────────────────
|
|
700
698
|
//
|
|
701
|
-
// Intercepts ez.showAds() to
|
|
702
|
-
//
|
|
703
|
-
//
|
|
699
|
+
// Intercepts ez.showAds() to filter disconnected placeholders and
|
|
700
|
+
// block calls during navigation. Matches v50 behavior: individual calls,
|
|
701
|
+
// no batching.
|
|
704
702
|
|
|
705
703
|
function patchShowAds() {
|
|
706
704
|
const apply = () => {
|
|
@@ -711,46 +709,18 @@
|
|
|
711
709
|
window.__nbbEzPatched = true;
|
|
712
710
|
|
|
713
711
|
const orig = ez.showAds.bind(ez);
|
|
714
|
-
const queue = new Set();
|
|
715
|
-
let flushTimer = null;
|
|
716
|
-
|
|
717
|
-
const flush = () => {
|
|
718
|
-
flushTimer = null;
|
|
719
|
-
if (isBlocked() || !queue.size) return;
|
|
720
|
-
const ids = Array.from(queue).sort((a, b) => a - b);
|
|
721
|
-
queue.clear();
|
|
722
|
-
const valid = ids.filter(id => {
|
|
723
|
-
const ph = document.getElementById(`${PH_PREFIX}${id}`);
|
|
724
|
-
if (!ph?.isConnected) { state.phState.delete(id); return false; }
|
|
725
|
-
if (isPlaceholderUsed(ph)) { state.phState.set(id, 'shown'); return false; }
|
|
726
|
-
return true;
|
|
727
|
-
});
|
|
728
|
-
for (let i = 0; i < valid.length; i += LIMITS.BATCH_SIZE) {
|
|
729
|
-
const chunk = valid.slice(i, i + LIMITS.BATCH_SIZE);
|
|
730
|
-
try { orig(...chunk); } catch (_) {
|
|
731
|
-
for (const cid of chunk) { try { orig(cid); } catch (_) {} }
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
|
|
736
712
|
ez.showAds = function (...args) {
|
|
737
|
-
// No-arg call = Ezoic page refresh — pass through
|
|
738
|
-
if (args.length === 0)
|
|
739
|
-
return orig();
|
|
740
|
-
}
|
|
713
|
+
// No-arg call = Ezoic internal page refresh — pass through
|
|
714
|
+
if (args.length === 0) return orig();
|
|
741
715
|
if (isBlocked()) return;
|
|
742
716
|
const ids = args.length === 1 && Array.isArray(args[0]) ? args[0] : args;
|
|
717
|
+
const seen = new Set();
|
|
743
718
|
for (const v of ids) {
|
|
744
719
|
const id = parseInt(v, 10);
|
|
745
|
-
if (!Number.isFinite(id) || id <= 0) continue;
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
state.phState.set(id, 'show-queued');
|
|
750
|
-
queue.add(id);
|
|
751
|
-
}
|
|
752
|
-
if (queue.size && !flushTimer) {
|
|
753
|
-
flushTimer = setTimeout(flush, TIMING.BATCH_FLUSH_MS);
|
|
720
|
+
if (!Number.isFinite(id) || id <= 0 || seen.has(id)) continue;
|
|
721
|
+
if (!document.getElementById(`${PH_PREFIX}${id}`)?.isConnected) continue;
|
|
722
|
+
seen.add(id);
|
|
723
|
+
try { orig(id); } catch (_) {}
|
|
754
724
|
}
|
|
755
725
|
};
|
|
756
726
|
} catch (_) {}
|
|
@@ -844,15 +814,6 @@
|
|
|
844
814
|
function cleanup() {
|
|
845
815
|
state.blockedUntil = now() + TIMING.BLOCK_DURATION_MS;
|
|
846
816
|
|
|
847
|
-
// Tell Ezoic to destroy all placeholders BEFORE we remove DOM elements.
|
|
848
|
-
// This prevents GPT slotDestroyed events and Ezoic 400 errors.
|
|
849
|
-
try {
|
|
850
|
-
const ez = window.ezstandalone;
|
|
851
|
-
if (typeof ez?.destroyAll === 'function') {
|
|
852
|
-
ez.destroyAll();
|
|
853
|
-
}
|
|
854
|
-
} catch (_) {}
|
|
855
|
-
|
|
856
817
|
mutate(() => {
|
|
857
818
|
for (const w of document.querySelectorAll(`.${WRAP_CLASS}`)) dropWrap(w);
|
|
858
819
|
});
|
|
@@ -1120,15 +1081,8 @@
|
|
|
1120
1081
|
|
|
1121
1082
|
$(window).off('.nbbEzoic');
|
|
1122
1083
|
|
|
1123
|
-
//
|
|
1124
|
-
$(window).on('action:ajaxify.start.nbbEzoic',
|
|
1125
|
-
const targetUrl = data?.url || data?.tpl_url || '';
|
|
1126
|
-
const currentPath = location.pathname.replace(/^\//, '');
|
|
1127
|
-
if (targetUrl && targetUrl.replace(/[?#].*$/, '') === currentPath.replace(/[?#].*$/, '')) {
|
|
1128
|
-
return; // Same page — skip cleanup
|
|
1129
|
-
}
|
|
1130
|
-
cleanup();
|
|
1131
|
-
});
|
|
1084
|
+
// Cleanup on every navigation, same as v50
|
|
1085
|
+
$(window).on('action:ajaxify.start.nbbEzoic', cleanup);
|
|
1132
1086
|
|
|
1133
1087
|
$(window).on('action:ajaxify.end.nbbEzoic', () => {
|
|
1134
1088
|
state.pageKey = pageKey();
|