Created
November 21, 2023 23:29
-
-
Save kolbykskk/f5db43cb67c70a8858bb544fe975ab9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
document.addEventListener('DOMContentLoaded', function() { | |
function modifyReturnOrderButtons() { | |
const email = document.querySelector('.frcp-nav__email').innerText; | |
const returnButtons = document.querySelectorAll('.frcp-order__return-btn:not([data-modified])'); | |
returnButtons.forEach(originalButton => { | |
originalButton.dataset.modified = 'true'; | |
const clonedButton = originalButton.cloneNode(true); | |
originalButton.parentNode.replaceChild(clonedButton, originalButton); | |
const orderName = clonedButton.closest('.frcp-order').querySelector('.frcp-order__name').innerText; | |
const newUrl = `https://hairtoppers.com/pages/dev-returns?name=${encodeURIComponent(orderName)}&email=${email}`; | |
clonedButton.addEventListener('click', event => { | |
window.location.href = newUrl; | |
}); | |
}); | |
} | |
const observer = new MutationObserver(modifyReturnOrderButtons); | |
observer.observe(document.body, { childList: true, subtree: true }); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment