nodebb-plugin-ezoic-infinite 1.2.2 → 1.2.3
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 +2 -44
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -35,10 +35,6 @@
|
|
|
35
35
|
seenTopicAnchors: new WeakSet(),
|
|
36
36
|
seenPostAnchors: new WeakSet(),
|
|
37
37
|
|
|
38
|
-
// FIFO for recycling
|
|
39
|
-
fifoTopics: [],
|
|
40
|
-
fifoPosts: [],
|
|
41
|
-
|
|
42
38
|
// showAds anti-double
|
|
43
39
|
lastShowById: new Map(),
|
|
44
40
|
pendingById: new Set(),
|
|
@@ -123,12 +119,6 @@
|
|
|
123
119
|
function safeRect(el) {
|
|
124
120
|
try { return el.getBoundingClientRect(); } catch (e) { return null; }
|
|
125
121
|
}
|
|
126
|
-
|
|
127
|
-
function destroyPlaceholder(id) {
|
|
128
|
-
try {
|
|
129
|
-
if (window.ezstandalone && typeof window.ezstandalone.destroyPlaceholders === 'function') {
|
|
130
|
-
window.ezstandalone.destroyPlaceholders([id]);
|
|
131
|
-
}
|
|
132
122
|
} catch (e) {}
|
|
133
123
|
}
|
|
134
124
|
|
|
@@ -216,41 +206,14 @@
|
|
|
216
206
|
if (attempts < 40) setTimeout(waitForPh, 50);
|
|
217
207
|
})();
|
|
218
208
|
}
|
|
219
|
-
|
|
220
|
-
function recycleOne(pool, usedSet, fifo, wrapperSelector) {
|
|
221
|
-
const margin = 1600;
|
|
222
|
-
const topLimit = -margin;
|
|
223
|
-
|
|
224
|
-
for (let i = 0; i < fifo.length; i++) {
|
|
225
|
-
const old = fifo[i];
|
|
226
|
-
const w = document.querySelector(wrapperSelector(old));
|
|
227
|
-
if (!w) { fifo.splice(i, 1); i--; continue; }
|
|
228
|
-
|
|
229
|
-
const r = safeRect(w);
|
|
230
|
-
if (r && r.bottom < topLimit) {
|
|
231
|
-
fifo.splice(i, 1);
|
|
232
|
-
w.remove();
|
|
233
|
-
usedSet.delete(old.id);
|
|
234
|
-
destroyPlaceholder(old.id);
|
|
235
|
-
pool.push(old.id);
|
|
236
|
-
return true;
|
|
237
|
-
}
|
|
238
209
|
}
|
|
239
210
|
return false;
|
|
240
211
|
}
|
|
241
212
|
|
|
242
213
|
function nextId(kind) {
|
|
243
|
-
const
|
|
244
|
-
const pool = isTopics ? state.poolTopics : state.poolPosts;
|
|
245
|
-
const used = isTopics ? state.usedTopics : state.usedPosts;
|
|
246
|
-
const fifo = isTopics ? state.fifoTopics : state.fifoPosts;
|
|
247
|
-
const sel = isTopics
|
|
248
|
-
? (old) => `.${WRAP_CLASS}.ezoic-ad-between[data-ezoic-after="${old.after}"]`
|
|
249
|
-
: (old) => `.${WRAP_CLASS}.ezoic-ad-message[data-ezoic-after="${old.after}"]`;
|
|
250
|
-
|
|
214
|
+
const pool = (kind === 'between') ? state.poolTopics : state.poolPosts;
|
|
251
215
|
if (pool.length) return pool.shift();
|
|
252
|
-
|
|
253
|
-
return null;
|
|
216
|
+
return null; // stop injecting when pool is empty
|
|
254
217
|
}
|
|
255
218
|
|
|
256
219
|
async function fetchConfig() {
|
|
@@ -310,7 +273,6 @@
|
|
|
310
273
|
const wrap = insertAfter(li, id, 'ezoic-ad-between', pos);
|
|
311
274
|
if (!wrap) continue;
|
|
312
275
|
|
|
313
|
-
state.fifoTopics.push({ id, after: pos });
|
|
314
276
|
inserted += 1;
|
|
315
277
|
|
|
316
278
|
callShowAdsWhenReady(id);
|
|
@@ -350,7 +312,6 @@
|
|
|
350
312
|
const wrap = insertAfter(post, id, 'ezoic-ad-message', no);
|
|
351
313
|
if (!wrap) continue;
|
|
352
314
|
|
|
353
|
-
state.fifoPosts.push({ id, after: no });
|
|
354
315
|
inserted += 1;
|
|
355
316
|
|
|
356
317
|
callShowAdsWhenReady(id);
|
|
@@ -373,9 +334,6 @@
|
|
|
373
334
|
state.seenTopicAnchors = new WeakSet();
|
|
374
335
|
state.seenPostAnchors = new WeakSet();
|
|
375
336
|
|
|
376
|
-
state.fifoTopics = [];
|
|
377
|
-
state.fifoPosts = [];
|
|
378
|
-
|
|
379
337
|
state.lastShowById = new Map();
|
|
380
338
|
state.pendingById = new Set();
|
|
381
339
|
|