Don't move if we're found an appointment
This commit is contained in:
parent
15613c19fd
commit
d075d8ac3e
@ -25,6 +25,7 @@ let config = {
|
|||||||
};
|
};
|
||||||
let isRunning = false;
|
let isRunning = false;
|
||||||
let msg = "";
|
let msg = "";
|
||||||
|
let isFoundAppointment = false;
|
||||||
|
|
||||||
async function delay(ms) {
|
async function delay(ms) {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
@ -328,6 +329,16 @@ async function runner() {
|
|||||||
return;
|
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()) {
|
if (isNotEnglishPage()) {
|
||||||
await switchToEnglishPage();
|
await switchToEnglishPage();
|
||||||
}
|
}
|
||||||
@ -562,9 +573,10 @@ async function runner() {
|
|||||||
|
|
||||||
msg = `Found better appointment in ${consulate} at ${chosenDate} ${chosenTime}`;
|
msg = `Found better appointment in ${consulate} at ${chosenDate} ${chosenTime}`;
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
|
await sendNotification(msg);
|
||||||
|
|
||||||
if (!config.consulates[consulate].autobook) {
|
if (!config.consulates[consulate].autobook) {
|
||||||
await sendNotification(msg);
|
isFoundAppointment = true;
|
||||||
} else {
|
} else {
|
||||||
await delay(PAGE_WAIT_TIME);
|
await delay(PAGE_WAIT_TIME);
|
||||||
msg = `Auto booking in ${consulate} at ${chosenDate} ${chosenTime}`;
|
msg = `Auto booking in ${consulate} at ${chosenDate} ${chosenTime}`;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user