Fix updating current appointment date
This commit is contained in:
parent
2d3e1b01be
commit
968e764020
@ -318,7 +318,8 @@ async function runner() {
|
|||||||
}
|
}
|
||||||
let apptDate = new Date(apptInfo.querySelector("p.consular-appt").innerText.match(/\d{1,2} \w+, \d{4}/)[0]);
|
let apptDate = new Date(apptInfo.querySelector("p.consular-appt").innerText.match(/\d{1,2} \w+, \d{4}/)[0]);
|
||||||
apptDate = apptDate.toISOString().slice(0, 10);
|
apptDate = apptDate.toISOString().slice(0, 10);
|
||||||
if (config.apptDate && apptDate != config.apptDate) {
|
if (apptDate && apptDate != config.apptDate) {
|
||||||
|
console.log(`New appointment date: ${apptDate}, old: ${config.apptDate}`);
|
||||||
config.apptDate = apptDate;
|
config.apptDate = apptDate;
|
||||||
await chrome.storage.local.set({ "__apptDate": apptDate });
|
await chrome.storage.local.set({ "__apptDate": apptDate });
|
||||||
}
|
}
|
||||||
@ -330,6 +331,15 @@ async function runner() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (isAppointmentPage()) {
|
else if (isAppointmentPage()) {
|
||||||
|
// if no apptDate, fetch it from dashboard page
|
||||||
|
if (!config.apptDate) {
|
||||||
|
console.log('No appointment date is set, going back to dashboard');
|
||||||
|
window.location = window.location.pathname.replace(/schedule.*/g, "/account");
|
||||||
|
await delay(PAGE_WAIT_TIME);
|
||||||
|
isRunning = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// await chrome.storage.local.set({ "__status": "fetching consulates" });
|
// await chrome.storage.local.set({ "__status": "fetching consulates" });
|
||||||
let applicantForm = document.querySelector('form[action*="' + window.location.pathname + '"]');
|
let applicantForm = document.querySelector('form[action*="' + window.location.pathname + '"]');
|
||||||
if (applicantForm && applicantForm.method.toLowerCase() == "get") {
|
if (applicantForm && applicantForm.method.toLowerCase() == "get") {
|
||||||
@ -469,7 +479,11 @@ async function runner() {
|
|||||||
else if (isConfirmationPage) {
|
else if (isConfirmationPage) {
|
||||||
// go back to schedule after successful reschedule
|
// go back to schedule after successful reschedule
|
||||||
await delay(PAGE_WAIT_TIME);
|
await delay(PAGE_WAIT_TIME);
|
||||||
window.location = page.replace(/schedule.*/g, "");
|
config.apptDate = null;
|
||||||
|
await chrome.storage.local.set({"__apptDate": config.apptDate});
|
||||||
|
console.log('Rescheduled successfully');
|
||||||
|
window.location = window.location.pathname.replace(/schedule.*/g, "");
|
||||||
|
await delay(PAGE_WAIT_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('runner done');
|
// console.log('runner done');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user