JSFiddle - React, Tailwind, and code Playground

HTML

<div opep="1" opep-popup-url="//new-link">
  <a href="//old-link">click me</a>
  <div opep="1" opep-popup-url="//new-link">
  <a href="//old-link">click me</a>
  </div>
</div>

JavaScript

jQuery(document).ready(function( $ ) {

	function opepSetLinksPopups() {

    $(document).find('[opep="1"]').each(function() {
      const popupUrl = $(this).attr('opep-popup-url');

      $(this).find('a:not([no-opep])').each(function () {
        const postUrl = $(this).attr('href');
        $(this).attr('post-url', postUrl);
        $(this).prop('href', popupUrl);
      });
    });
  }
  
  opepSetLinksPopups();
    
});