3.0.2 - The custom shortcut feature wasn't working
+
3.0.1 - Bug fixes and removing redundant code
+
3.0.0 - The beginning of BestSEQTA, I am forking the project to take it in a new direction
+
2.0.7 - Added support to other domains + Minor bug fixes
Fixed BestSEQTA not loading on some pages
Fixed text colour of notices being unreadable
Fixed pages not reloading when saving changes
+
2.0.2 - Minor bug fixes
Fixed indicator for current lesson
Fixed text colour for DM messages list in Light mode
Fixed user info text colour
+
Sleek New Layout
Updated with a new font and presentation, BestSEQTA has never looked better.
+
New Updated Sidebar
Condensed appearance with new updated icons.
+
Independent Light Mode and Dark Mode
Dark mode and Light mode are now available to pick alongside your chosen Theme Colour. Your Theme Colour will now become an accent colour for the page.
+ Light/Dark mode can be toggled with the new button, found in the top-right of the menu bar.
+
+
+
Create Custom Shortcuts
Found in the BestSEQTA Settings menu, custom shortcuts can now be created with a name and URL of your choice.
`
+ }
+
+ if (lesson.assessments.length > 0) {
+ for (let i = 0; i < lesson.assessments.length; i++) {
+ const element = lesson.assessments[i]
+ assessmentstring += `
${element.title}
`
+ }
+ lessonstring += `
${assessmentstring}
`
+ }
+ lessonstring += '
';
+ var lessondiv = stringToHTML(lessonstring);
+ return lessondiv;
+}
+
+function CheckUnmarkedAttendance(lessonattendance) {
+ if (lessonattendance) {
+ var lesson = lessonattendance.label;
+ }
+ else {
+ var lesson = " ";
+ }
+ return lesson;
+}
+
+function callHomeTimetable(date, change) {
+ // Creates a HTTP Post Request to the SEQTA page for the students timetable
+ var xhr = new XMLHttpRequest();
+ xhr.open(
+ "POST",
+ `${location.origin}/seqta/student/load/timetable?`,
+ true
+ );
+ // Sets the response type to json
+ xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
+
+ xhr.onreadystatechange = function () {
+ // Once the response is ready
+ if (xhr.readyState === 4) {
+ var serverResponse = JSON.parse(xhr.response);
+ lessonArray = [];
+ var DayContainer = document.getElementById("day-container")
+ // If items in response:
+ if (serverResponse.payload.items.length > 0) {
+ if (!DayContainer.innerText || change) {
+ // console.log(serverResponse.payload.items.length);
+ for (let i = 0; i < serverResponse.payload.items.length; i++) {
+ lessonArray.push(serverResponse.payload.items[i]);
+ }
+ lessonArray.sort(function (a, b) {
+ return a.from.localeCompare(b.from);
+ });
+ // If items in the response, set each corresponding value into divs
+ // lessonArray = lessonArray.splice(1)
+ GetLessonColours().then((colours) => {
+ subjects = colours;
+ for (let i = 0; i < lessonArray.length; i++) {
+
+ subjectname = `timetable.subject.colour.${lessonArray[i].code}`
+
+ subject = subjects.find(element => element.name === subjectname)
+ if (!subject) {
+ lessonArray[i].colour = `--item-colour: #8e8e8e;`
+ }
+ else {
+ lessonArray[i].colour = `--item-colour: ${subject.value};`
+ result = GetThresholdofHex(subject.value);
+
+ if (result > 300) {
+ lessonArray[i].invert = true;
+ }
+ }
+ // Removes seconds from the start and end times
+ lessonArray[i].from = lessonArray[i].from.substring(0, 5);
+ lessonArray[i].until = lessonArray[i].until.substring(0, 5);
+
+ // Checks if attendance is unmarked, and sets the string to " ".
+ lessonArray[i].attendanceTitle = CheckUnmarkedAttendance(
+ lessonArray[i].attendance)
+ }
+ // If on home page, apply each lesson to HTML with information in each div
+ DayContainer.innerText = '';
+ for (let i = 0; i < lessonArray.length; i++) {
+ var div = MakeLessonDiv(lessonArray[i], i + 1);
+ // Append each of the lessons into the day-container
+ if (lessonArray[i].invert) {
+ div.firstChild.classList.add('day-inverted');
+ }
+
+ DayContainer.append(div.firstChild);
+ }
+
+ const today = new Date();
+ if (currentSelectedDate.getDate() == today.getDate()) {
+ for (i = 0; i < lessonArray.length; i++) {
+ CheckCurrentLesson(lessonArray[i], i + 1);
+ }
+ // For each lesson, check the start and end times
+ CheckCurrentLessonAll(lessonArray);
+ }
+ })
+
+
+ }
+ }
+ else {
+ if (!DayContainer.innerText || change) {
+ DayContainer.innerText = '';
+ var dummyDay = document.createElement("div");
+ dummyDay.classList.add("day-empty");
+ img = document.createElement('img')
+ img.src = chrome.runtime.getURL('icons/betterseqta-light-icon.png')
+ text = document.createElement('p')
+ text.innerText = "No lessons available."
+ dummyDay.append(img);
+ dummyDay.append(text);
+ DayContainer.append(dummyDay);
+ }
+ }
+ }
+ };
+ xhr.send(
+ JSON.stringify({
+ // Information sent to SEQTA page as a request with the dates and student number
+ from: date,
+ until: date,
+ // Funny number
+ student: 69,
+ })
+ );
+}
+
+function GetUpcomingAssessments() {
+
+ func = fetch(`${location.origin}/seqta/student/assessment/list/upcoming?`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ },
+ body: JSON.stringify({ "student": 69 })
+ })
+
+ return func
+ .then((result) => result.json())
+ .then(response => (response.payload))
+}
+
+function GetActiveClasses() {
+ func = fetch(`${location.origin}/seqta/student/load/subjects?`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ },
+ body: JSON.stringify({})
+ })
+
+ return func
+ .then((result) => result.json())
+ .then(response => (response.payload))
+}
+
+function comparedate(obj1, obj2) {
+ if (obj1.date < obj2.date) {
+ return -1;
+ }
+ if (obj1.date > obj2.date) {
+ return 1;
+ }
+ return 0;
+}
+
+function CreateElement(type, class_, id, innerText, innerHTML, style) {
+ element = document.createElement(type);
+ if (class_ !== undefined) {
+ element.classList.add(class_);
+ }
+ if (id !== undefined) {
+ element.id = id;
+ }
+ if (innerText !== undefined) {
+ element.innerText = innerText;
+ }
+ if (innerHTML !== undefined) {
+ element.innerHTML = innerHTML;
+ }
+ if (style !== undefined) {
+ element.style = style;
+ }
+ return element
+}
+
+function createAssessmentDateDiv(date, value, datecase = undefined) {
+ var options = { weekday: 'long', month: 'long', day: 'numeric' };
+ const FormattedDate = new Date(date)
+
+ const assessments = value.assessments;
+ const container = value.div;
+
+ DateTitleDiv = document.createElement('div');
+ DateTitleDiv.classList.add('upcoming-date-title');
+
+ if (datecase) {
+ datetitle = document.createElement('h5');
+ datetitle.classList.add('upcoming-special-day')
+ datetitle.innerText = datecase;
+ DateTitleDiv.append(datetitle);
+ container.setAttribute('data-day', datecase);
+ }
+
+ DateTitle = document.createElement('h5')
+ DateTitle.innerText = FormattedDate.toLocaleDateString("en-AU", options);
+ DateTitleDiv.append(DateTitle);
+
+
+
+ container.append(DateTitleDiv);
+
+ assessmentContainer = document.createElement('div')
+ assessmentContainer.classList.add('upcoming-date-assessments');
+
+ for (let i = 0; i < assessments.length; i++) {
+ const element = assessments[i];
+ item = document.createElement('div')
+ item.classList.add('upcoming-assessment');
+ item.setAttribute('data-subject', element.code);
+ item.id = `assessment${element.id}`;
+
+ item.style = element.colour;
+
+ titlediv = document.createElement('div');
+ titlediv.classList.add('upcoming-subject-title');
+
+ titlesvg = stringToHTML(``).firstChild
+ titlediv.append(titlesvg);
+
+ detailsdiv = document.createElement('div');
+ detailsdiv.classList.add('upcoming-details');
+ detailstitle = document.createElement('h5');
+ detailstitle.innerText = `${element.subject} assessment`;
+ subject = document.createElement('p');
+ subject.innerText = element.title;
+ subject.classList.add('upcoming-assessment-title');
+ subject.onclick = function () { location.href = `../#?page=/assessments/${element.programmeID}:${element.metaclassID}&item=${element.id}` };
+ detailsdiv.append(detailstitle);
+ detailsdiv.append(subject);
+
+ item.append(titlediv);
+ item.append(detailsdiv);
+ assessmentContainer.append(item);
+
+ fetch(`${location.origin}/seqta/student/assessment/submissions/get`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ },
+ body: JSON.stringify({ "assessment": element.id, "metaclass": element.metaclassID, "student": 69 })
+ })
+ .then((result) => result.json())
+ .then((response) => {
+ if (response.payload.length > 0) {
+ const assessment = document.querySelector(`#assessment${element.id}`);
+
+ // ticksvg = stringToHTML(``).firstChild
+ // ticksvg.classList.add('upcoming-tick');
+ // assessment.append(ticksvg);
+ submittedtext = document.createElement('div')
+ submittedtext.classList.add('upcoming-submittedtext');
+ submittedtext.innerText = "Submitted";
+ assessment.append(submittedtext);
+
+
+ }
+ })
+
+
+
+ }
+
+ container.append(assessmentContainer);
+
+ return container;
+
+}
+
+function CheckSpecialDay(date1, date2) {
+ if (
+ date1.getFullYear() === date2.getFullYear() &&
+ date1.getMonth() === date2.getMonth() &&
+ (date1.getDate() - 1) === date2.getDate()
+ ) {
+ return "Yesterday";
+ }
+ if (
+ date1.getFullYear() === date2.getFullYear() &&
+ date1.getMonth() === date2.getMonth() &&
+ date1.getDate() === date2.getDate()
+ ) {
+ TodayinUpcoming = true;
+ return "Today";
+ }
+ if (
+ date1.getFullYear() === date2.getFullYear() &&
+ date1.getMonth() === date2.getMonth() &&
+ (date1.getDate() + 1) === date2.getDate()
+ ) {
+ TomorrowinUpcoming = true;
+ return "Tomorrow";
+ }
+}
+
+function CreateDateCheckedDiv(text, date) {
+ upcomingitemcontainer = document.querySelector('#upcoming-items')
+ container = CreateElement(type = 'div', class_ = 'upcoming-date-container');
+ datecontainer = CreateElement(type = 'div', class_ = 'upcoming-date-title');
+ titletext = CreateElement(type = 'h5', class_ = 'upcoming-special-day', id = undefined, innerText = text);
+ titledate = CreateElement(type = 'h5', class_ = undefined, id = undefined, innerText = date);
+
+ textcontainer = CreateElement('div', 'upcoming-blank')
+ textblank = CreateElement('p');
+ textblank.innerText = 'No assessments due';
+
+ textcontainer.append(textblank)
+
+ datecontainer.append(titletext);
+ datecontainer.append(titledate);
+
+ container.append(datecontainer);
+ container.append(textcontainer)
+ upcomingitemcontainer.append(container);
+}
+
+
+
+function CreateSubjectFilter(subjectcode, itemcolour, checked) {
+ label = CreateElement('label', "upcoming-checkbox-container")
+ label.innerText = subjectcode;
+ input = CreateElement('input');
+ input.type = "checkbox";
+ input.checked = checked;
+ input.id = `filter-${subjectcode}`;
+ label.style = itemcolour;
+ span = CreateElement('span', 'upcoming-checkmark')
+ label.append(input);
+ label.append(span);
+
+ input.addEventListener('change', function (change) {
+ chrome.storage.local.get(null, function (storage) {
+ filters = storage.subjectfilters;
+ id = change.target.id.split('-')[1]
+ filters[id] = change.target.checked
+
+ chrome.storage.local.set({ subjectfilters: filters })
+ })
+ })
+
+ return label
+}
+
+function CreateFilters(subjects) {
+ chrome.storage.local.get(null, function (result) {
+ filteroptions = result.subjectfilters
+
+ filterdiv = document.querySelector('#upcoming-filters')
+ for (let i = 0; i < subjects.length; i++) {
+ const element = subjects[i];
+ if (!filteroptions.hasOwnProperty(element.code)) {
+ filteroptions[element.code] = true;
+ chrome.storage.local.set({ subjectfilters: filteroptions });
+ }
+ elementdiv = CreateSubjectFilter(element.code, element.colour, filteroptions[element.code])
+
+ filterdiv.append(elementdiv)
+ }
+ })
+}
+
+
+
+function CreateUpcomingSection(assessments) {
+ upcomingitemcontainer = document.querySelector('#upcoming-items')
+ homecontainer = document.querySelector('#home-container')
+ overdueDates = [];
+ upcomingDates = {};
+ TodayinUpcoming = false;
+ TomorrowinUpcoming = false;
+
+ // date = '2022/3/20';
+ // var Today = new Date(date);
+
+ var Today = new Date();
+
+ // Removes overdue assessments from the upcoming assessments array and pushes to overdue array
+ for (let i = 0; i < assessments.length; i++) {
+ const element = assessments[i];
+ assessmentdue = new Date(element.due);
+
+ CheckSpecialDay(Today, assessmentdue)
+ if (assessmentdue < Today) {
+ if (!CheckSpecialDay(Today, assessmentdue)) {
+ overdueDates.push(element);
+ assessments.splice(i, 1);
+ i--;
+ }
+ }
+ }
+ var options = { weekday: 'long', month: 'long', day: 'numeric' };
+ if (!TodayinUpcoming) {
+ text = Today.toLocaleDateString("en-AU", options);
+ CreateDateCheckedDiv("Today", text);
+ }
+
+ function addTomorrowinUpcoming() {
+ // var TomorrowDate = new Date(date);
+ var TomorrowDate = new Date();
+ TomorrowDate.setDate((TomorrowDate.getDate() + 1))
+ textDate = TomorrowDate.toLocaleDateString("en-AU", options);
+ CreateDateCheckedDiv("Tomorrow", textDate);
+ }
+
+ if (!TomorrowinUpcoming && !TodayinUpcoming) {
+ addTomorrowinUpcoming();
+ }
+
+ GetLessonColours().then((colours) => {
+ subjects = colours;
+ for (let i = 0; i < assessments.length; i++) {
+
+ subjectname = `timetable.subject.colour.${assessments[i].code}`
+
+ subject = subjects.find(element => element.name === subjectname)
+ if (!subject) {
+ assessments[i].colour = `--item-colour: #8e8e8e;`
+ }
+ else {
+ assessments[i].colour = `--item-colour: ${subject.value};`
+ result = GetThresholdofHex(subject.value);
+ }
+ }
+
+ for (let i = 0; i < activeSubjects.length; i++) {
+ const element = activeSubjects[i];
+ subjectname = `timetable.subject.colour.${element.code}`
+ colour = colours.find(element => element.name === subjectname);
+ if (!colour) {
+ element.colour = `--item-colour: #8e8e8e;`
+ }
+ else {
+ element.colour = `--item-colour: ${colour.value};`
+ result = GetThresholdofHex(colour.value);
+ if (result > 300) {
+ element.invert = true;
+ }
+ }
+
+ }
+
+
+ CreateFilters(activeSubjects);
+
+
+
+ for (let i = 0; i < assessments.length; i++) {
+ const element = assessments[i];
+ if (!upcomingDates[element.due]) {
+ dateObj = new Object();
+ dateObj.div = CreateElement(type = 'div', class_ = 'upcoming-date-container')
+ dateObj.assessments = [];
+
+ upcomingDates[element.due] = dateObj;
+ }
+ assessmentDateDiv = upcomingDates[element.due];
+ assessmentDateDiv.assessments.push(element);
+ }
+
+ for (var date in upcomingDates) {
+
+ assessmentdue = new Date(upcomingDates[date].assessments[0].due);
+ specialcase = CheckSpecialDay(Today, assessmentdue);
+
+ if (specialcase) {
+ assessmentDate = createAssessmentDateDiv(date, upcomingDates[date], datecase = specialcase);
+ } else {
+ assessmentDate = createAssessmentDateDiv(date, upcomingDates[date]);
+ }
+
+ if (specialcase === 'Yesterday') {
+ upcomingitemcontainer.insertBefore(assessmentDate, upcomingitemcontainer.firstChild);
+ } else {
+ upcomingitemcontainer.append(assessmentDate)
+ }
+
+ if (specialcase === 'Today' && !TomorrowinUpcoming) {
+ addTomorrowinUpcoming();
+ }
+
+
+ }
+ chrome.storage.local.get(null, function (result) {
+ FilterUpcomingAssessments(result.subjectfilters);
+ })
+ })
+}
+
+function AddPlaceHolderToParent(parent, numberofassessments) {
+ textcontainer = CreateElement('div', 'upcoming-blank')
+ textblank = CreateElement('p', 'upcoming-hiddenassessment');
+ s = "";
+ if (numberofassessments > 1) {
+ s = "s";
+ }
+ textblank.innerText = `${numberofassessments} hidden assessment${s} due`;
+ textcontainer.append(textblank);
+ textcontainer.setAttribute('data-hidden', true);
+
+ parent.append(textcontainer);
+}
+
+function FilterUpcomingAssessments(subjectoptions) {
+ for (var item in subjectoptions) {
+ subjectdivs = document.querySelectorAll(`[data-subject="${item}"]`);
+
+ for (let i = 0; i < subjectdivs.length; i++) {
+ const element = subjectdivs[i];
+
+ if (!subjectoptions[item]) {
+ element.classList.add('hidden');
+ }
+ if (subjectoptions[item]) {
+ element.classList.remove('hidden');
+ }
+ element.parentNode.classList.remove('hidden');
+
+ children = element.parentNode.parentNode.children
+ for (let i = 0; i < children.length; i++) {
+ const element = children[i];
+ if (element.hasAttribute('data-hidden')) {
+ element.remove();
+ }
+ }
+
+ if (element.parentNode.children.length == element.parentNode.querySelectorAll(".hidden").length) {
+ if (element.parentNode.querySelectorAll(".hidden").length > 0) {
+ if (!element.parentNode.parentNode.hasAttribute('data-day')) {
+ element.parentNode.parentNode.classList.add('hidden');
+ } else {
+ AddPlaceHolderToParent(element.parentNode.parentNode, element.parentNode.querySelectorAll(".hidden").length)
+ }
+ }
+
+
+ }
+ else {
+ element.parentNode.parentNode.classList.remove('hidden');
+ }
+ }
+
+
+ }
+
+}
+
+chrome.storage.onChanged.addListener(function (changes) {
+ if (changes.subjectfilters) {
+ FilterUpcomingAssessments(changes.subjectfilters.newValue);
+ }
+})
+
+function GetLessonColours() {
+ func = fetch(`${location.origin}/seqta/student/load/prefs?`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ },
+ body: JSON.stringify({ "request": "userPrefs", "asArray": true, "user": 69 })
+ })
+ return func
+ .then((result) => result.json())
+ .then(response => (response.payload))
+}
+
+function CreateCustomShortcutDiv(element) {
+ // Creates the stucture and element information for each seperate shortcut
+ var shortcut = document.createElement("a");
+ shortcut.setAttribute("href", element.url);
+ shortcut.setAttribute("target", "_blank");
+ var shortcutdiv = document.createElement("div");
+ shortcutdiv.classList.add("shortcut");
+ shortcutdiv.classList.add("customshortcut");
+
+ image = stringToHTML(``).firstChild
+ image.classList.add("shortcuticondiv");
+ var text = document.createElement("p");
+ text.textContent = element.name;
+ shortcutdiv.append(image);
+ shortcutdiv.append(text);
+ shortcut.append(shortcutdiv);
+
+ document.getElementById("shortcuts").append(shortcut);
+}
+
+function AddCustomShortcutsToPage() {
+ chrome.storage.local.get(["customshortcuts"], function (result) {
+ var customshortcuts = Object.values(result)[0];
+ if (customshortcuts.length > 0) {
+ document.getElementsByClassName("shortcut-container")[0].style.display = "block";
+ for (let i = 0; i < customshortcuts.length; i++) {
+ const element = customshortcuts[i];
+ CreateCustomShortcutDiv(element);
+ }
+ }
+ });
+}
+
+function SendHomePage() {
+ setTimeout(function () {
+ // Sends the html data for the home page
+ console.log("[BestSEQTA] Loading Home Page");
+ document.title = "Home ― SEQTA Learn";
+ var element = document.querySelector("[data-key=home]");
+
+ // Apply the active class to indicate clicked on home button
+ element.classList.add("active");
+
+ // Remove all current elements in the main div to add new elements
+ var main = document.getElementById("main");
+ main.innerHTML = "";
+
+ const titlediv = document.getElementById('title').firstChild;
+ titlediv.innerText = "Home";
+ document.querySelector('link[rel*="icon"]').href = chrome.extension.getURL("icons/icon-48.png");
+
+ currentSelectedDate = new Date();
+
+ // Creates the root of the home page added to the main div
+ var htmlStr =
+ `
`;
+
+ var html = stringToHTML(htmlStr);
+ // Appends the html file to main div
+ // Note : firstChild of html is done due to needing to grab the body from the stringToHTML function
+ main.append(html.firstChild);
+
+ // Gets the current date
+ const date = new Date();
+
+ // Formats the current date used send a request for timetable and notices later
+ var TodayFormatted =
+ date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
+
+ // Replaces actual date with a selected date. Used for testing.
+ // TodayFormatted = "2020-08-31";
+
+
+ // Creates the shortcut container into the home container
+ var ShortcutStr = `
`;
+ var Shortcut = stringToHTML(ShortcutStr);
+ // Appends the shortcut container into the home container
+ document.getElementById("home-container").append(Shortcut.firstChild);
+
+ // Creates the container div for the timetable portion of the home page
+ var TimetableStr = `
Today's Lessons
`;
+ var Timetable = stringToHTML(TimetableStr);
+ // Appends the timetable container into the home container
+ document.getElementById("home-container").append(Timetable.firstChild);
+
+ var timetablearrowback = document.getElementById('home-timetable-back')
+ var timetablearrowforward = document.getElementById('home-timetable-forward')
+
+ function SetTimetableSubtitle() {
+ var homelessonsubtitle = document.getElementById('home-lesson-subtitle');
+ const date = new Date();
+ if (date.getYear() == currentSelectedDate.getYear() && date.getMonth() == currentSelectedDate.getMonth()) {
+ if (date.getDate() == currentSelectedDate.getDate()) {
+ // Change text to Today's Lessons
+ homelessonsubtitle.innerText = "Today's Lessons";
+ }
+ else if ((date.getDate() - 1) == currentSelectedDate.getDate()) {
+ // Change text to Yesterday's Lessons
+ homelessonsubtitle.innerText = "Yesterday's Lessons";
+ }
+ else if ((date.getDate() + 1) == currentSelectedDate.getDate()) {
+ // Change text to Tomorrow's Lessons
+ homelessonsubtitle.innerText = "Tomorrow's Lessons";
+ }
+ else {
+ // Change text to date of the day
+ homelessonsubtitle.innerText = `${currentSelectedDate.toLocaleString('en-us', { weekday: 'short' })} ${currentSelectedDate.toLocaleDateString('en-au')}`;
+ }
+ }
+ else {
+ // Change text to date of the day
+ homelessonsubtitle.innerText = `${currentSelectedDate.toLocaleString('en-us', { weekday: 'short' })} ${currentSelectedDate.toLocaleDateString('en-au')}`;
+ }
+ }
+
+ function changeTimetable(value) {
+ currentSelectedDate.setDate(currentSelectedDate.getDate() + value);
+ FormattedDate = currentSelectedDate.getFullYear() + "-" + (currentSelectedDate.getMonth() + 1) + "-" + currentSelectedDate.getDate();
+ callHomeTimetable(FormattedDate, true);
+ SetTimetableSubtitle();
+ }
+
+ timetablearrowback.addEventListener('click', function () { changeTimetable(-1) })
+ timetablearrowforward.addEventListener('click', function () { changeTimetable(1) })
+
+
+ assessmentsicon = ``
+ coursesicon = ``
+
+ function createNewShortcut(link, icon, viewBox, title) {
+ // Creates the stucture and element information for each seperate shortcut
+ var shortcut = document.createElement("a");
+ shortcut.setAttribute("href", link);
+ shortcut.setAttribute("target", "_blank");
+ var shortcutdiv = document.createElement("div");
+ shortcutdiv.classList.add("shortcut");
+
+ image = stringToHTML(``).firstChild
+ image.classList.add("shortcuticondiv");
+ var text = document.createElement("p");
+ text.textContent = title;
+ shortcutdiv.append(image);
+ shortcutdiv.append(text);
+ shortcut.append(shortcutdiv);
+
+ document.getElementById("shortcuts").append(shortcut);
+ }
+ // Adds the shortcuts to the shortcut container
+ chrome.storage.local.get(["shortcuts"], function (result) {
+ var shortcuts = Object.values(result)[0];
+ for (let i = 0; i < shortcuts.length; i++) {
+ if (shortcuts[i].enabled) {
+ Itemname = (shortcuts[i].name).replace(/ /g, '')
+ createNewShortcut(
+ ShortcutLinks[Itemname].link,
+ ShortcutLinks[Itemname].icon,
+ ShortcutLinks[Itemname].viewBox,
+ shortcuts[i].name
+ );
+ }
+ }
+ AddCustomShortcutsToPage();
+
+ // Checks if shortcut container is empty
+ if (document.getElementById("shortcuts").childElementCount == 0) {
+ // If there are no shortcuts, hide the container
+ document.getElementsByClassName("shortcut-container")[0].style.display = "none";
+ }
+ });
+
+
+ // Creates the upcoming container and appends to the home container
+ var upcomingcontainer = document.createElement('div');
+ upcomingcontainer.classList.add('upcoming-container');
+ upcomingcontainer.classList.add('border');
+
+
+ upcomingtitlediv = CreateElement('div', 'upcoming-title');
+ upcomingtitle = document.createElement('h2');
+ upcomingtitle.classList.add('home-subtitle');
+ upcomingtitle.innerText = 'Upcoming Assessments';
+ upcomingtitlediv.append(upcomingtitle);
+
+ upcomingfilterdiv = CreateElement('div', 'upcoming-filters', 'upcoming-filters');
+ upcomingtitlediv.append(upcomingfilterdiv)
+
+ upcomingcontainer.append(upcomingtitlediv);
+
+
+
+ upcomingitems = document.createElement('div');
+ upcomingitems.id = 'upcoming-items';
+ upcomingitems.classList.add('upcoming-items');
+
+ upcomingcontainer.append(upcomingitems);
+
+ document.getElementById("home-container").append(upcomingcontainer);
+
+
+ // Creates the notices container into the home container
+ var NoticesStr = `
Notices
`;
+ var Notices = stringToHTML(NoticesStr);
+ // Appends the shortcut container into the home container
+ document.getElementById("home-container").append(Notices.firstChild);
+
+ callHomeTimetable(TodayFormatted);
+
+
+ // Sends similar HTTP Post Request for the notices
+ var xhr2 = new XMLHttpRequest();
+ xhr2.open(
+ "POST",
+ `${location.origin}/seqta/student/load/notices?`,
+ true
+ );
+ xhr2.setRequestHeader("Content-Type", "application/json; charset=utf-8");
+
+ xhr2.onreadystatechange = function () {
+ if (xhr2.readyState === 4) {
+ var NoticesPayload = JSON.parse(xhr2.response);
+ var NoticeContainer = document.getElementById("notice-container");
+ if (NoticesPayload.payload.length == 0) {
+ if (!NoticeContainer.innerText) {
+ // If no notices: display no notices
+ var dummyNotice = document.createElement("div");
+ dummyNotice.textContent = "No notices for today.";
+ dummyNotice.classList.add("dummynotice");
+ NoticeContainer.append(dummyNotice);
+ }
+
+ } else {
+ if (!NoticeContainer.innerText) {
+ // For each element in the response json:
+ chrome.storage.local.get(["DarkMode"], function (result) {
+ for (let i = 0; i < NoticesPayload.payload.length; i++) {
+ // Create a div, and place information from json response
+ var NewNotice = document.createElement("div");
+ NewNotice.classList.add("notice");
+ var title = stringToHTML(
+ `
` + NoticesPayload.payload[i].title + `
`
+ );
+ NewNotice.append(title.firstChild);
+
+ if (NoticesPayload.payload[i].label_title != undefined) {
+ var label = stringToHTML(
+ `
`
+ );
+ NewNotice.append(staff.firstChild);
+ // Converts the string into HTML
+ var content = stringToHTML(NoticesPayload.payload[i].contents);
+ for (let i = 0; i < content.childNodes.length; i++) {
+ NewNotice.append(content.childNodes[i]);
+ }
+ // Gets the colour for the top section of each notice
+
+
+ var colour = NoticesPayload.payload[i].colour;
+ if (typeof (colour) == "string") {
+ rgb = GetThresholdofHex(colour);
+ DarkModeResult = result.DarkMode
+ if (rgb < 100 && DarkModeResult) {
+ colour = undefined;
+ }
+ }
+
+ var colourbar = document.createElement("div");
+ colourbar.classList.add("colourbar");
+ colourbar.style.background = "var(--colour)";
+ NewNotice.style = `--colour: ${colour}`;
+ // Appends the colour bar to the new notice
+ NewNotice.append(colourbar);
+ // Appends the new notice into the notice container
+ NoticeContainer.append(NewNotice);
+
+ }
+ });
+ }
+ }
+ }
+ };
+ // Data sent as the POST request
+ xhr2.send(JSON.stringify({ date: TodayFormatted }));
+
+ // Sends similar HTTP Post Request for the notices
+ chrome.storage.local.get(null, function (result) {
+ if (result.notificationcollector) {
+ var xhr3 = new XMLHttpRequest();
+ xhr3.open(
+ "POST",
+ `${location.origin}/seqta/student/heartbeat?`,
+ true
+ );
+ xhr3.setRequestHeader(
+ "Content-Type",
+ "application/json; charset=utf-8"
+ );
+ xhr3.onreadystatechange = function () {
+ if (xhr3.readyState === 4) {
+ var Notifications = JSON.parse(xhr3.response);
+ var alertdiv = document.getElementsByClassName(
+ "notifications__bubble___1EkSQ"
+ )[0];
+ if (typeof alertdiv == 'undefined') {
+ console.log("[BestSEQTA] Your inbox is clean")
+
+ }
+ else {
+ alertdiv.textContent = Notifications.payload.notifications.length;
+ }
+ }
+ };
+ xhr3.send(
+ JSON.stringify({
+ timestamp: "1970-01-01 00:00:00.0",
+ hash: "#?page=/home",
+ })
+ );
+ }
+ });
+
+ GetUpcomingAssessments()
+ .then((assessments) => {
+ GetActiveClasses().then((classes) => {
+
+ // Gets all subjects for the student
+ for (let i = 0; i < classes.length; i++) {
+ const element = classes[i];
+ if (element.hasOwnProperty('active')) {
+ // Finds the active class list with the current subjects
+ activeClassList = classes[i]
+ }
+ }
+ activeSubjects = activeClassList.subjects
+
+ activeSubjectCodes = []
+ // Gets the code for each of the subjects and puts them in an array
+ for (let i = 0; i < activeSubjects.length; i++) {
+ const element = activeSubjects[i];
+ activeSubjectCodes.push(element.code)
+ }
+
+ CurrentAssessments = []
+ for (let i = 0; i < assessments.length; i++) {
+ const element = assessments[i];
+ if (activeSubjectCodes.includes(element.code)) {
+ CurrentAssessments.push(element)
+ }
+ }
+
+
+
+ CurrentAssessments.sort(comparedate);
+
+
+ CreateUpcomingSection(CurrentAssessments, activeSubjects);
+
+
+ // Run function to check if gap between assessments > 7 days?
+
+ })
+
+ });
+
+ }, 8);
+}
+
+function SendNewsPage() {
+ setTimeout(function () {
+ // Sends the html data for the home page
+ console.log("[BestSEQTA] Started Loading News Page");
+ document.title = "News ― SEQTA Learn";
+ var element = document.querySelector("[data-key=news]");
+
+ // Apply the active class to indicate clicked on home button
+ element.classList.add("active");
+
+ // Remove all current elements in the main div to add new elements
+ var main = document.getElementById("main");
+ main.innerHTML = "";
+
+ // Creates the root of the home page added to the main div
+ var htmlStr =
+ `