-
-
Save Rovack/51e0fb558ee0fa4ce0e2cd5f0ab17cb1 to your computer and use it in GitHub Desktop.
// Note that this has some limitations, such as looking specifically for adult tickets, | |
// looking for the given days only in the nearest month that has availability, | |
// and always choosing the earliest time if several are found within the desired dates. | |
function setAdultTickets(adultTicketsWanted) { | |
const adultTicketsCount = parseInt($('.quantity-control.row > input')[0].value, 10); | |
const ticketChangeIterations = Math.abs(adultTicketsWanted - adultTicketsCount); | |
const ticketChangeButton = $(`.quantity-control.row > button.typcn-${adultTicketsCount < adultTicketsWanted ? 'plus' : 'minus'}`)[0]; | |
for (let i = 0; i < ticketChangeIterations; i++) { | |
ticketChangeButton.click(); | |
} | |
} | |
function playSound(src) { | |
return new Promise((resolve) => { | |
const audio = new Audio(src); | |
audio.onended = resolve; | |
audio.play(); | |
}); | |
} | |
function repeatHeyListen() { | |
playSound('https://www.myinstants.com/media/sounds/hey_listen.mp3') | |
.then(repeatHeyListen); | |
} | |
function waitForAvailability() { | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
const availableEls = $('.calendar>.row:not(.blankLoader) .calendar-body .day.available'), isLoading = $('.calendar-modal[data-component=eventTimeModal] .modal-content > .loading-mask.hide').length === 0; | |
if (isLoading) { | |
return waitForAvailability() | |
.then((res) => resolve(res)); | |
} | |
resolve(availableEls); | |
}, 1000); | |
}); | |
} | |
function playSounds() { | |
playSound('https://www.myinstants.com/media/sounds/mlg-airhorn.mp3') | |
.then(() => playSound('https://www.myinstants.com/media/sounds/sound-9______.mp3')) | |
.then(() => playSound('https://www.myinstants.com/media/sounds/ps_1.mp3')) | |
.then(() => playSound('https://www.myinstants.com/media/sounds/wrong-answer-sound-effect.mp3')) | |
.then(() => playSound('https://www.myinstants.com/media/sounds/lalalalala.swf.mp3')) | |
.then(() => playSound('https://www.myinstants.com/media/sounds/tuturu_1.mp3')) | |
.then(() => playSound('https://www.myinstants.com/media/sounds/hallelujahshort.swf.mp3')) | |
.then(repeatHeyListen); | |
} | |
function addTicketsToBasket(dayElement) { | |
dayElement.click(); | |
setTimeout(() => waitForAvailability() | |
.then(() => { | |
$('.ui-control.button.select-time')[0].click(); | |
setTimeout(() => { | |
$('.typcn.typcn-shopping-cart.ng-binding')[0].click(); | |
}, 2000); | |
}), 2000); | |
} | |
function checkForTickets(datesWanted=[6, 7, 8], adultTicketsWanted=2, checkFrequency=15) { | |
setAdultTickets(adultTicketsWanted); | |
function check() { | |
$('.shared-calendar-button').click(); | |
waitForAvailability() | |
.then(availableEls => { | |
console.log(new Date(), 'Availability loaded. Checking for relevant dates...'); | |
for (let i = 0; i < availableEls.length; i++) { | |
const day = parseInt(availableEls[i].innerText, 10); | |
console.log('Day', day, 'is available...'); | |
if (datesWanted.includes(day)) { | |
console.log('Found tickets!!!!!'); | |
playSounds(); | |
addTicketsToBasket(availableEls[i]); | |
return; | |
} | |
} | |
console.log(`Relevant dates not yet available. Will check again in ${checkFrequency} seconds.`); | |
$('#page > div:nth-child(11) > div.modal.info-modal.w-auto-c > div > div.close').click(); | |
setTimeout(check, checkFrequency * 1000); | |
}); | |
}; | |
check(); | |
} |
I tried this command but still got the same error. The quickest way to reproduce it is by purchasing through this website—issues pop up way more often than with regular ticket purchases, which should make it easier for you to pinpoint the problem
thanks again!!!!!
Tried through the Pricessless link you shared, but I still can't get it to reproduce. I set the refresh rate to 1 second hoping it'd happen quickly, but even after a few hundred refreshes, I never ran into this issue.
Could you share what parameters you're using when running this (dates, etc)? Maybe they affect this somehow.
But either way, it occurs to me that one possible explanation for why the script stops is that the loading indicator doesn't clear properly when their code crashes, which means the script keeps waiting forever for loading to finish.
We can easily solve that by capping the amount of time it waits - the only problem is that I'm not sure that even if we detect these cases and try to reopen the dialog, the site will still be functioning properly once we do. Still, worth a shot.
Probably all you'd have to do is replace the waitForAvailability
function with, say:
maxAttempts = 10;
function waitForAvailability(attempt = 1) {
if (attempt > maxAttempts) return Promise.resolve([]);
return new Promise((resolve) => {
setTimeout(() => {
const availableEls = $('.calendar>.row:not(.blankLoader) .calendar-body .day.available'), isLoading = $('.calendar-modal[data-component=eventTimeModal] .modal-content > .loading-mask.hide').length === 0;
if (isLoading) {
return waitForAvailability(attempt + 1)
.then((res) => resolve(res));
}
resolve(availableEls);
}, 1000);
});
}
(If you're using the code version that allows you to select a month too it'd be slightly different; just let me know if so and I can send over a modified version of that as well.)
If this still doesn't work because the site just stops working whenever it runs into that error, then I suppose we'd have to either fix their code so it doesn't crash to begin with, figure out some way to hard-refresh the page while keeping the script running, or at least notify you loudly so you can manually refresh...
None of the options sounds that simple, so let's just hope this works, and see what we can do if not.
Hey @huoshenw. That looks like the same issue that @athko described back in 2023, but as far as I know it hasn't recurred in nearly 2 years... And as noted there, it appears to be an error in the code of the website itself, and not the script, which makes it all the more puzzling.
I suspect the reason it's stopping the script is that it's an unhandled error, so perhaps it's interrupting any running code including ours.If so, it's possible that pasting something like the following in the Console before the script will, while not addressing the error itself, at least allow the script to continue refreshing and trying even after it happens (though I can't say for sure as I'm unable to reproduce the problem myself):[Edit: Strikethroughs added since this turned out not to work.]
Beyond that, I just wonder why only some people seem to be running into this issue...
I'd think it's a timing issue (a "race condition"), but that wouldn't really explain why some folks have it happen quite frequently, whereas I've never encountered it even once.
I suppose it could be specific to some browser/OS/unusual set of circumstances - any chance that if you try a different browser it stops happening?