Skip to content

Commit

Permalink
- Add a single dummy IFTTT event to trigger unmute for all day events
Browse files Browse the repository at this point in the history
  • Loading branch information
PardhavMaradani committed Sep 17, 2024
1 parent 90a2ac3 commit ab48f9f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
39 changes: 24 additions & 15 deletions content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function exportExamScheduleICS() {
// Generate Assignment Upload events and export ICS file
function generateAssignmentEventsAndExport(semester, courseAssignments) {
let events = [];
let dummyEventAdded = {};
for (let i = 0; i < courseAssignments.length; i++) {
const course = courseAssignments[i];
for (let j = 0; j < course.assignments.length; j++) {
Expand All @@ -147,6 +148,9 @@ function generateAssignmentEventsAndExport(semester, courseAssignments) {
'Course Title: ' + course.title + '\\n' +
'Course Type: ' + course.type + '\\n' +
'Assignment Title: ' + assignment.title;
if (assignment.dueDate == '-') {
continue;
}
const date = new Date(Date.parse(assignment.dueDate));
const nextDate = new Date(date);
nextDate.setDate(date.getDate() + 1);
Expand All @@ -157,14 +161,16 @@ function generateAssignmentEventsAndExport(semester, courseAssignments) {
end: getICSDateOnly(nextDate)
};
events.push(event);
// Add dummy event for IFTTT to trigger on event end and unmute
const eventForIFTTT = {
summary: summary,
description: description,
start: getICSDateTime(date, '00:15'),
end: getICSDateTime(date, '00:30'),
};
events.push(eventForIFTTT);
if (!(date in dummyEventAdded)) {
// Add dummy event for IFTTT to trigger on event end and unmute
const eventForIFTTT = {
summary: 'Dummy event to trigger IFTTT unmute for all day events',
start: getICSDateTime(date, '00:15'),
end: getICSDateTime(date, '00:30'),
};
events.push(eventForIFTTT);
dummyEventAdded[date] = true;
}
}
}
const calName = 'VIT-Assignment-Upload-Schedule-' + semester.replace(/ /g, '-');
Expand Down Expand Up @@ -372,6 +378,7 @@ function parseACal() {
// Generate Timetable events as per Academic Calendar and export
function generateTTEventsAndExport(semester, courses, tt, ac) {
let events = [];
let dummyEventAdded = {};
// Iterate over all days of academic calendar
const weekdays = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'];
for (let monthYear in ac) {
Expand Down Expand Up @@ -428,13 +435,15 @@ function generateTTEventsAndExport(semester, courses, tt, ac) {
end: getICSDateOnly(nextDate)
};
events.push(event);
// Add dummy event for IFTTT to trigger on event end and unmute
const eventForIFTTT = {
summary: info + ' ' + detail,
start: getICSDateTime(date, '00:15'),
end: getICSDateTime(date, '00:30'),
};
events.push(eventForIFTTT);
if (!(date in dummyEventAdded)) {
// Add dummy event for IFTTT to trigger on event end and unmute
const eventForIFTTT = {
summary: 'Dummy event to trigger IFTTT unmute for all day events',
start: getICSDateTime(date, '00:15'),
end: getICSDateTime(date, '00:30'),
};
events.push(eventForIFTTT);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "VIT Timetable Export",
"version": "1.4",
"version": "1.5",
"description": "Export VIT Timetable as iCalendar (.ics) File",
"permissions": ["contextMenus", "scripting", "activeTab"],
"background": {
Expand Down

0 comments on commit ab48f9f

Please sign in to comment.