diff --git a/src/appointments.ts b/src/appointments.ts index 77fbc77..eaf7dbc 100644 --- a/src/appointments.ts +++ b/src/appointments.ts @@ -95,6 +95,11 @@ async function proceedWithACode(page: Page, impfCode: string) { await appointmentWarning?.getProperty("innerText") )?.jsonValue(); + if (await areWeOffline(page)) { + debug("We are offline or on some different page"); + return false; + } + if ( !appointmentWarning || !appointmentText || @@ -107,6 +112,7 @@ async function proceedWithACode(page: Page, impfCode: string) { debug("No appointments"); return false; } + export async function proceedWithoutACode(page: Page) { debug("Checking without a code"); // no, we have no code @@ -124,6 +130,11 @@ export async function proceedWithoutACode(page: Page) { const appointmentWarning = await page.$("div.alert.alert-danger"); + if (await areWeOffline(page)) { + debug("We are offline or on some different page"); + return false; + } + if (!appointmentWarning) { // code available debug("Appointments available!!"); @@ -133,6 +144,10 @@ export async function proceedWithoutACode(page: Page) { return false; } +async function areWeOffline(page: Page) { + return !(await page.$("footer-copyright")); +} + export async function checkForAppointments( page: Page, impfLocationUrl: string,