Integration with Existing Code:
Called checkAndResetDaily before the initial exec() call and in the "Start" menu command to ensure the counter is reset if a new day has started.
Added a setTimeout in the exec function to check for midnight. It calculates the milliseconds until midnight (msUntilMidnight) and schedules a check to reset and rerun the script if a new day is detected.