Skip to content

Commit

Permalink
fixed issue fetching schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
digas99 committed Jan 14, 2023
1 parent fb27b12 commit c180a25
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [Changelog v1.2.2](https://github.com/digas99/schedule-ua/releases/tag/v1.2.2)

### Bug Fixes
- Fixed issue where schedules with overalapping classes couldn't be fetched


# [Changelog v1.2.1](https://github.com/digas99/schedule-ua/releases/tag/v1.2.1)

## Bug Fixes
Expand Down
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,10 @@ Browser Extension for easy access to your Schedule from Universidade de Aveiro.

## Latest Features

## [Changelog v1.2.1](https://github.com/digas99/schedule-ua/releases/tag/v1.2.1)
## [Changelog v1.2.2](https://github.com/digas99/schedule-ua/releases/tag/v1.2.2)

### Bug Fixes
- Fixed bug of Changelog not loading in about page
- Changing pages within the extension while using a color theme doesn't flicker white anymore
- Fixed issue where choosing a subject color with the color picker on settings would break if many colors were clicked within the color picker (now, the color is only saved when the color picker is closed)
- Clicking on a class from a subject that has only one day on the schedule now shows the info panel on the right, instead of showing just one full sized schedule with one single day

### Popup
- Added button to lateral navbar to list all the subjects from the current schedule
- Color Themes:
- Sapphire
- Ambar
- Fixed issue where schedules with overalapping classes couldn't be fetched

[(All changelogs)](CHANGELOG.md)

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "SchedUA",
"description": "Unoficial extension to easily look up your schedule from Universidade de Aveiro.",
"version": "1.2.1",
"version": "1.2.2",
"manifest_version": 3,
"action": {
"default_popup": "login.html"
Expand Down
20 changes: 14 additions & 6 deletions scripts/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"Segunda": [],"Terça": [],"Quarta": [],"Quinta": [],"Sexta": [],"Sábado": []
}
};

if (table) {
// info
const scheduleInfoElem = table.querySelector("tr").children[0];
let scheduleType;

let scheduleType, subjectsList;
// subject schedule
if (scheduleInfoElem.childNodes.length == 1) {
scheduleType = "subject";
Expand All @@ -29,6 +29,12 @@
const scheduleInfo = scheduleInfoElem.childNodes[2].wholeText;
data["school_year"] = scheduleInfo.split(" - ")[1].split("AnoLectivo: ")[1];
data["semester"] = Number(scheduleInfo.split(" - ")[2].split("º")[0]);

// subjects list
subjectsTable = table.nextElementSibling;
while (subjectsTable && subjectsTable.tagName != "TABLE") subjectsTable = subjectsTable.nextElementSibling;

subjectsList = Array.from(new Set(Array.from(subjectsTable.querySelectorAll("tr > td:nth-of-type(2)")).map(info => info.innerText.split(" (")[0].trim())));
}

// subjects
Expand All @@ -53,7 +59,8 @@
subject = {
"subject": {
"name": titleData[0],
"abbrev": elem.childNodes[0].wholeText.split(" ")[0].replace("\n", "")
"abbrev": elem.childNodes[0].wholeText.split(" ")[0].replace("\n", ""),
"code": subjectsList.filter(subject => subject.split(" - ")[1] === titleData[0])[0].split(" - ")[0]
},
"start": titleData[2].split("INÍCIO: ")[1],
"duration": titleData[3].split("DURAÇÃO: ")[1],
Expand All @@ -64,8 +71,9 @@
}

weekday.push(subject);
});
}

});
}

return data;
}
Expand Down

0 comments on commit c180a25

Please sign in to comment.