Ebay EPN: Source map error

Thanks for the info @Falco and happy birthday.

I figured out the problem was where I added that <script src="… line.

This worked for me:

<script type="text/discourse-plugin" version="0.8">

  console.log(settings.epn_id);
  window._epn = {campaign: settings.epn_id, smartPopover:false};

  var script = document.createElement('script');
  script.src = 'https://epnt.ebay.com/static/epn-smart-tools.js';
  var head = document.getElementsByTagName("head")[0];
  head.appendChild(script);

</script>

The next problem I ran into is that elements that are dynamically loaded are do not have the script applied to them. For instance, if I refresh the page on a topic, the posts that load will have the affiliate link but scrolling to reveal more posts - those ones don’t.

Is there a way to run the script every time a new element is loaded?