Code:
// Time based download control // Trigger: "Interval" (Recommended: 300000 ms) var t1 = [2, 20]; // <- Set starting time (hours = 0-23, minutes = 0-59) var t2 = [7, 44]; // <- Set ending time (hours = 0-23, minutes = 0-59) var now = new Date(); if (now > time(t1[0], t1[1]) && now < time(t2[0], t2[1])) { if (!isDownloadControllerRunning() && downloadsPending()) startDownloads(); } else { if (isDownloadControllerRunning()) stopDownloads(); } //Functions function time(hh, mm) { return new Date().setHours(hh, mm, 0, 0) } function downloadsPending() { return getAllDownloadLinks().some(function(link) { return link.getFinalLinkStatus() == null; }); }