Do processing only in working hours
This commit is contained in:
parent
d075d8ac3e
commit
bcdcd0001a
@ -329,6 +329,16 @@ async function runner() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if current time is between 11pm and 9am UTC (4pm - 2am PST)
|
||||
let now = new Date();
|
||||
let currentHourUTC = now.getUTCHours();
|
||||
if (currentHourUTC >= 23 || currentHourUTC < 9) {
|
||||
// Continue running the code
|
||||
} else {
|
||||
isRunning = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isFoundAppointment) {
|
||||
// don't do anything if appointment is found and manual booking is required
|
||||
if (isAppointmentPage()) {
|
||||
@ -506,11 +516,20 @@ async function runner() {
|
||||
|
||||
// if empty list, either we're banned or non operational hours or dead consulate
|
||||
// wait for some time before checking again
|
||||
let now = new Date();
|
||||
let currentHourUTC = now.getUTCHours();
|
||||
let currentMinuteUTC = now.getUTCMinutes();
|
||||
|
||||
if (availDates.length == 0) {
|
||||
msg = `No available dates in ${consulate}, probably banned`;
|
||||
console.log(msg);
|
||||
await chrome.storage.local.set({ "__status": msg });
|
||||
config.consulates[consulate].nextCheckAt = getFutureDate(SOFT_BAN_TIMEOUT, 10);
|
||||
|
||||
// Only set SOFT_BAN_TIMEOUT if it's not the first 5 minutes of 23pm UTC
|
||||
if (!(currentHourUTC === 23 && currentMinuteUTC < 5)) {
|
||||
config.consulates[consulate].nextCheckAt = getFutureDate(SOFT_BAN_TIMEOUT, 10);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user