Sure! Can you try maybe this variation:
add_action('wp_footer', 'asp_custom_footer_script', 99999);
function asp_custom_footer_script() {
?>
<script>
window.addEventListener("load", (event) => {
(function($){
$('.asp_m').on('asp_elementor_results', function(){
let id = $(this).data('id');
let seen = [];
$('.asp_es_' + id + ' .elementor-post').each(function(){
if ( seen.includes(this.className) ) {
$(this).remove();
} else {
seen.push(this.className);
}
});
});
}(WPD.dom));
});
</script>
<?php
}