diff --git a/scripts/content.js b/scripts/content.js index 8ebf9e0..6e3f548 100644 --- a/scripts/content.js +++ b/scripts/content.js @@ -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}`;