nodebb-plugin-ezoic-infinite 0.6.5 → 0.6.6
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 +14 -8
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -14,7 +14,7 @@ let rerunRequested = false;
|
|
|
14
14
|
let pageKey = null;
|
|
15
15
|
let injectedSlots = new Set(); // slot numbers already injected on this page
|
|
16
16
|
let usedIds = new Set(); // IDs currently present in DOM
|
|
17
|
-
let adsFIFO = []; // [{
|
|
17
|
+
let adsFIFO = []; // [{slot, id}] oldest first
|
|
18
18
|
|
|
19
19
|
function resetPageState() {
|
|
20
20
|
injectedSlots = new Set();
|
|
@@ -73,14 +73,21 @@ function getCategoryTopicItems() {
|
|
|
73
73
|
return $('li[component="category/topic"]').not('.ezoic-ad-topic');
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
// IMPORTANT: Use the SAME tag type as the surrounding list container.
|
|
77
|
+
// If posts/topics are in a <ul>/<ol>, the wrapper MUST be a <li> or the browser may move it outside the list (often to the top).
|
|
78
|
+
function wrapperTagFor($target) {
|
|
79
|
+
if (!$target || !$target.length) return 'div';
|
|
80
|
+
const parentTag = ($target.parent().prop('tagName') || '').toUpperCase();
|
|
81
|
+
if (parentTag === 'UL' || parentTag === 'OL') return 'li';
|
|
82
|
+
const selfTag = ($target.prop('tagName') || '').toUpperCase();
|
|
83
|
+
if (selfTag === 'LI') return 'li';
|
|
84
|
+
return 'div';
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
function makeWrapperLike($target, classes, innerHtml, attrs) {
|
|
81
|
-
const
|
|
88
|
+
const tag = wrapperTagFor($target);
|
|
82
89
|
const attrStr = attrs ? ' ' + attrs : '';
|
|
83
|
-
if (
|
|
90
|
+
if (tag === 'li') {
|
|
84
91
|
return '<li class="' + classes + ' list-unstyled"' + attrStr + '>' + innerHtml + '</li>';
|
|
85
92
|
}
|
|
86
93
|
return '<div class="' + classes + '"' + attrStr + '>' + innerHtml + '</div>';
|
|
@@ -153,7 +160,6 @@ function injectBetweenIncremental($items, pool, interval, wrapperClass) {
|
|
|
153
160
|
|
|
154
161
|
let id = pickNextId(pool);
|
|
155
162
|
if (!id) {
|
|
156
|
-
// Pool full: evict oldest, then reuse freed ID
|
|
157
163
|
if (!evictOldestOne()) break;
|
|
158
164
|
id = pickNextId(pool);
|
|
159
165
|
if (!id) break;
|
|
@@ -171,7 +177,7 @@ function injectBetweenIncremental($items, pool, interval, wrapperClass) {
|
|
|
171
177
|
|
|
172
178
|
injectedSlots.add(slot);
|
|
173
179
|
usedIds.add(id);
|
|
174
|
-
adsFIFO.push({
|
|
180
|
+
adsFIFO.push({ slot: slot, id: id });
|
|
175
181
|
newIds.push(id);
|
|
176
182
|
}
|
|
177
183
|
|
|
@@ -211,7 +217,7 @@ function injectMessageIncremental($posts, pool, interval) {
|
|
|
211
217
|
|
|
212
218
|
injectedSlots.add(slot);
|
|
213
219
|
usedIds.add(id);
|
|
214
|
-
adsFIFO.push({
|
|
220
|
+
adsFIFO.push({ slot: slot, id: id });
|
|
215
221
|
newIds.push(id);
|
|
216
222
|
}
|
|
217
223
|
|