Don't move if we're found an appointment

This commit is contained in:
Maks Snegov 2024-04-25 23:00:44 -07:00
parent 15613c19fd
commit d075d8ac3e

View File

@ -25,6 +25,7 @@ let config = {
};
let isRunning = false;
let msg = "";
let isFoundAppointment = false;
async function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
@ -328,6 +329,16 @@ async function runner() {
return;
}
if (isFoundAppointment) {
// don't do anything if appointment is found and manual booking is required
if (isAppointmentPage()) {
isRunning = false;
return;
// we're not on an appointment page, so seems like we're done, and we can check dates again
} else {
isFoundAppointment = false;
}
if (isNotEnglishPage()) {
await switchToEnglishPage();
}
@ -562,9 +573,10 @@ async function runner() {
msg = `Found better appointment in ${consulate} at ${chosenDate} ${chosenTime}`;
console.log(msg);
await sendNotification(msg);
if (!config.consulates[consulate].autobook) {
await sendNotification(msg);
isFoundAppointment = true;
} else {
await delay(PAGE_WAIT_TIME);
msg = `Auto booking in ${consulate} at ${chosenDate} ${chosenTime}`;