Redirect if element is shown in embedded form

I need your help redirecting the page which has embedded form and if the element is shown, I want it to redirect the a certain page. Thank you!

<script>
if ( receipt number (element) is shown it will redirect below ) {
  window.location.href = "https://www.example.com";
}
</script> ```