Created
December 20, 2019 13:12
-
-
Save stevgouws/e5525a0a60cbf69372a54d473c7a7ba1 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
<style id="hide-choose-num-tickets-style-tag"> | |
section.choose-num-tickets { | |
display: none; | |
} | |
</style> | |
<script> | |
window.onload = () => { | |
let chooseTicketTypeHeading; | |
let numberOfTicketsButton; | |
const isGiftCardBookingPage = window.location.href.includes("/book/199G2-gift-card"); | |
if (!isGiftCardBookingPage) return; | |
attemptCustomisation(); | |
function attemptCustomisation(retryCount = 0) { | |
if (!loaded()) { | |
retry(retryCount); | |
} else { | |
applyCustomisation(); | |
} | |
} | |
function loaded() { | |
chooseTicketTypeHeading = document.querySelector("#best-available>ticket-type>left-right-title p"); | |
numberOfTicketsButton = document.querySelector(".num-tickets-container .choice") | |
return Boolean(chooseTicketTypeHeading && numberOfTicketsButton); | |
} | |
function retry(retryCount) { | |
retryCount += 1; | |
if (retryCount > 50) { | |
cancelCustomisation(); | |
return; | |
}; | |
setTimeout(() => { | |
attemptCustomisation(retryCount); | |
}, 200); | |
} | |
function cancelCustomisation() { | |
document.getElementById("hide-choose-num-tickets-style-tag").remove(); | |
} | |
function applyCustomisation() { | |
chooseTicketTypeHeading.innerText = "Choose Gift Card value"; | |
numberOfTicketsButton.click(); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment