nodebb-plugin-ezoic-infinite 1.6.25 → 1.6.26

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.6.25",
3
+ "version": "1.6.26",
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
@@ -1,36 +1,37 @@
1
1
  (function () {
2
2
  'use strict';
3
3
 
4
- function ezoicClosestTopicLi(el) {
4
+ function ezoicInsertAfterTopicHost(target, wrap, kindClass) {
5
5
  try {
6
- if (!el) return null;
7
- if (el.closest) {
8
- return el.closest('li[component="category/topic"]') || el.closest('li');
9
- }
10
- } catch (e) {}
11
- return null;
12
- }
13
-
14
- function ezoicPlaceBetweenInLi(target, wrap) {
15
- // Place between-ad WRAP inside the previous topic <li>, not as a sibling in the <ul>.
16
- try {
17
- var li = ezoicClosestTopicLi(target) || target;
18
- if (!li || !wrap) return false;
19
-
20
- // avoid duplicates per anchor+after
21
- try {
22
- var after = wrap.getAttribute && wrap.getAttribute('data-ezoic-after');
23
- if (after && li.querySelector) {
24
- var existing = li.querySelector('.nodebb-ezoic-wrap.ezoic-ad-between[data-ezoic-after="' + after + '"]');
25
- if (existing && existing !== wrap) {
26
- try { wrap.remove(); } catch(e) {}
27
- return true;
28
- }
29
- }
30
- } catch (e) {}
31
-
32
- try { wrap.setAttribute('data-ezoic-in-li', '1'); } catch (e) {}
33
- li.appendChild(wrap);
6
+ if (!target || !wrap) return false;
7
+ if (kindClass !== 'ezoic-ad-between') return false;
8
+
9
+ // Ensure we insert a LI host that looks like a topic item so NodeBB list virtualization keeps ordering.
10
+ var anchorLi = target.closest ? (target.closest('li[component="category/topic"]') || target.closest('li')) : null;
11
+ if (!anchorLi && target.tagName === 'LI') anchorLi = target;
12
+ if (!anchorLi) return false;
13
+
14
+ var ul = anchorLi.parentElement;
15
+ if (!ul || !(ul.tagName === 'UL' || ul.tagName === 'OL')) return false;
16
+
17
+ // If wrap already hosted, do nothing
18
+ var existingHost = wrap.closest ? wrap.closest('li.nodebb-ezoic-host') : null;
19
+ if (existingHost) return true;
20
+
21
+ var host = document.createElement('li');
22
+ host.className = 'nodebb-ezoic-host';
23
+ // mimic topic list item so NodeBB doesn't relocate it
24
+ host.setAttribute('component', 'category/topic');
25
+ host.setAttribute('data-ezoic-host', 'between');
26
+ host.style.listStyle = 'none';
27
+ host.style.width = '100%';
28
+
29
+ // Insert host after anchorLi
30
+ if (anchorLi.insertAdjacentElement) anchorLi.insertAdjacentElement('afterend', host);
31
+ else ul.insertBefore(host, anchorLi.nextSibling);
32
+
33
+ host.appendChild(wrap);
34
+ try { wrap.style.width = '100%'; } catch (e) {}
34
35
  return true;
35
36
  } catch (e) {}
36
37
  return false;
@@ -704,9 +705,7 @@ function globalGapFixInit() {
704
705
  insertingIds.add(id);
705
706
  try {
706
707
  const wrap = buildWrap(id, kindClass, afterPos, !existingPh);
707
- if (kindClass === 'ezoic-ad-between') {
708
- if (ezoicPlaceBetweenInLi(target, wrap)) return;
709
- }
708
+ if (ezoicInsertAfterTopicHost(target, wrap, kindClass)) return;
710
709
  target.insertAdjacentElement('afterend', wrap);
711
710
 
712
711
  // If placeholder exists elsewhere (including pool), move it into the wrapper.
@@ -1199,9 +1198,7 @@ function buildOrdinalMap(items) {
1199
1198
  if (!anchorEl || !wrap || !wrap.isConnected) return null;
1200
1199
 
1201
1200
  wrap.setAttribute('data-ezoic-after', String(afterPos));
1202
- if (kindClass === 'ezoic-ad-between') {
1203
- if (ezoicPlaceBetweenInLi(anchorEl, wrap)) return;
1204
- }
1201
+ if (ezoicInsertAfterTopicHost(anchorEl, wrap, kindClass)) return;
1205
1202
  anchorEl.insertAdjacentElement('afterend', wrap);
1206
1203
 
1207
1204
  // Ensure minimal layout impact.
@@ -1553,26 +1550,27 @@ function buildOrdinalMap(items) {
1553
1550
 
1554
1551
 
1555
1552
 
1556
- // ===== V15 one-shot repair (no heavy observers) =====
1557
- function ezoicRepairBetweenPlacement() {
1553
+ // ===== V16 repair invalid UL children (between) =====
1554
+ function ezoicRepairBetweenHosts() {
1558
1555
  try {
1559
1556
  var bad = document.querySelectorAll('ul > div.nodebb-ezoic-wrap.ezoic-ad-between, ol > div.nodebb-ezoic-wrap.ezoic-ad-between');
1560
1557
  bad.forEach(function(wrap){
1561
1558
  try {
1562
1559
  var prev = wrap.previousElementSibling;
1563
- if (prev) ezoicPlaceBetweenInLi(prev, wrap);
1560
+ if (!prev) return;
1561
+ ezoicInsertAfterTopicHost(prev, wrap, 'ezoic-ad-between');
1564
1562
  } catch (e) {}
1565
1563
  });
1566
1564
  } catch (e) {}
1567
1565
  }
1568
- try { ezoicRepairBetweenPlacement(); } catch (e) {}
1566
+ try { ezoicRepairBetweenHosts(); } catch (e) {}
1569
1567
  if (window.jQuery) {
1570
1568
  try {
1571
1569
  window.jQuery(window).on('action:ajaxify.end action:infiniteScroll.loaded', function(){
1572
- setTimeout(function(){ try { ezoicRepairBetweenPlacement(); } catch(e) {} }, 0);
1573
- setTimeout(function(){ try { ezoicRepairBetweenPlacement(); } catch(e) {} }, 250);
1570
+ setTimeout(function(){ try { ezoicRepairBetweenHosts(); } catch(e) {} }, 0);
1571
+ setTimeout(function(){ try { ezoicRepairBetweenHosts(); } catch(e) {} }, 250);
1574
1572
  });
1575
1573
  } catch (e) {}
1576
1574
  }
1577
- // ===== /V15 =====
1575
+ // ===== /V16 =====
1578
1576
 
package/public/style.css CHANGED
@@ -81,15 +81,14 @@
81
81
  }
82
82
 
83
83
 
84
- /* ===== V15 between in li ===== */
85
- li[component="category/topic"] > .nodebb-ezoic-wrap.ezoic-ad-between[data-ezoic-in-li="1"] {
86
- display: block;
87
- width: 100%;
88
- margin-top: 12px;
89
- margin-bottom: 12px;
84
+ /* ===== V16 host topic li ===== */
85
+ li.nodebb-ezoic-host[component="category/topic"]{
86
+ list-style:none;
87
+ width:100%;
90
88
  }
91
- li[component="category/topic"] > .nodebb-ezoic-wrap.ezoic-ad-between[data-ezoic-in-li="1"] * {
92
- max-width: 100%;
89
+ /* ensure host doesn't inherit topic card layout */
90
+ li.nodebb-ezoic-host[component="category/topic"] > .nodebb-ezoic-wrap.ezoic-ad-between{
91
+ width:100%;
93
92
  }
94
- /* ===== /V15 ===== */
93
+ /* ===== /V16 ===== */
95
94