Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.9 kB
5
Indexable
Never
<!-- Start of Jewel ML Embed Code -->
<script defer>
if (document.querySelectorAll("script[src*='jewelml.io/r/d/']").length == 0) {
  var d = document || window.document;
  var s = 'script';
  var s0 = d.getElementsByTagName(s)[0];
  var ps = ['//rerender.jewelml.io/r/d/641debb196663d04095fb325/r.js'];
  ps.forEach(function(p) {
    var j = d.createElement(s);
    j.async = true;
    j.typetype = 'text/javascript';
    j.src = p;
    s0.parentNode.insertBefore(j, s0);
  });
} else {
  if (document.querySelectorAll("div[id*=-carousel]").length > 0) {
    RenderPlacements.renderPlacements(__jml_placements_params);
  }
}

var makeJewelObserver = function (selector, cb, elem) {
  elem = elem || document.body;
  var previousURL = window.location.href
  var observer = new MutationObserver(function (mutations) {
    if (previousURL !== window.location.href && document.querySelector("div[id*=-carousel]")) {
      previousURL = window.location.href
      cb(elem)
    } else {
      mutations.forEach(function(mutation) {
        if (mutation.type === 'childList') {
          Array.prototype.slice.call(mutation.addedNodes).forEach(function(addedNode) {
            if (addedNode.nodeType === 1 && addedNode.id && typeof addedNode.id.indexOf === 'function' && addedNode.id.indexOf(selector) !== -1) {
              cb(addedNode)
            }
          });
        }
      });
    }
    if (previousURL !== window.location.href) {
      previousURL = window.location.href
      cb(elem)
    }
  });
  observer.observe(elem, { subtree: true, childList: true })
  return observer
}

makeJewelObserver("div[id*=-carousel]", function (elem) {
  const url =window.location.pathname
  const match = url.match(/\/p\/([^?]+)/)
  if (match && match[1]) {
    const itemId = match[1]
    __jml_placements_params.item_id = itemId
  }
  RenderPlacements.renderPlacements(__jml_placements_params)
});
  
</script>
<!-- End of Jewel ML Embed Code -->