Do processing only in working hours
This commit is contained in:
parent
d075d8ac3e
commit
bcdcd0001a
@ -329,6 +329,16 @@ async function runner() {
|
|||||||
return;
|
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) {
|
if (isFoundAppointment) {
|
||||||
// don't do anything if appointment is found and manual booking is required
|
// don't do anything if appointment is found and manual booking is required
|
||||||
if (isAppointmentPage()) {
|
if (isAppointmentPage()) {
|
||||||
@ -506,11 +516,20 @@ async function runner() {
|
|||||||
|
|
||||||
// if empty list, either we're banned or non operational hours or dead consulate
|
// if empty list, either we're banned or non operational hours or dead consulate
|
||||||
// wait for some time before checking again
|
// wait for some time before checking again
|
||||||
|
let now = new Date();
|
||||||
|
let currentHourUTC = now.getUTCHours();
|
||||||
|
let currentMinuteUTC = now.getUTCMinutes();
|
||||||
|
|
||||||
if (availDates.length == 0) {
|
if (availDates.length == 0) {
|
||||||
msg = `No available dates in ${consulate}, probably banned`;
|
msg = `No available dates in ${consulate}, probably banned`;
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
await chrome.storage.local.set({ "__status": 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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user