diff --git a/scripts/content.js b/scripts/content.js index 6e3f548..3ac12c1 100644 --- a/scripts/content.js +++ b/scripts/content.js @@ -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; }