Skip to content

Commit 9946e9b

Browse files
committed
Merge branch 'hotfix/extraction'
2 parents 8a9c3f2 + 1ef2b50 commit 9946e9b

File tree

3 files changed

+38
-53
lines changed

3 files changed

+38
-53
lines changed

SECURITY.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
| [v1.1.9](https://github.com/FramedStone/SassyNic/releases/tag/v1.1.9) | :x: |
99
| [v1.3.0](https://github.com/FramedStone/SassyNic/releases/tag/v1.3.0) | :x: |
1010
| [v1.3.1](https://github.com/FramedStone/SassyNic/releases/tag/v1.3.1) | :x: |
11-
| [v1.3.2](https://github.com/FramedStone/SassyNic/releases/tag/v1.3.2) | :white_check_mark: |
11+
| [v1.3.2](https://github.com/FramedStone/SassyNic/releases/tag/v1.3.2) | :x: |
1212
| [v2.3.2](https://github.com/FramedStone/SassyNic/releases/tag/v2.3.2) | :x: |
1313
| [v2.3.3](https://github.com/FramedStone/SassyNic/releases/tag/v2.3.3) | :x: |
14-
| [v3.3.4](https://github.com/FramedStone/SassyNic/releases/tag/v3.3.4) | :white_check_mark: |
15-
| [v3.4.4](https://github.com/FramedStone/SassyNic/releases/tag/v3.4.4) | :white_check_mark: |
14+
| [v3.3.4](https://github.com/FramedStone/SassyNic/releases/tag/v3.3.4) | :x: |
15+
| [v3.4.4](https://github.com/FramedStone/SassyNic/releases/tag/v3.4.4) | :x: |
16+
| [v3.4.5](https://github.com/FramedStone/SassyNic/releases/tag/v3.4.5) | :white_check_mark: |
1617

1718

1819
## Reporting a Vulnerability

SassyNic-Student/extension/scripts/extraction.js

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -208,59 +208,43 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
208208
* Function that extract class details and process extracted data
209209
*/
210210
function extractClassDetails() {
211-
const rows = document.querySelectorAll('.ps_grid-row'); // select all rows in the table
212-
const subjectTitle = document
213-
.getElementById('SSR_CRSE_INFO_V_COURSE_TITLE_LONG')
214-
.textContent.trim();
215-
const subjectCode = document.getElementById('SSR_CRSE_INFO_V_SSS_SUBJ_CATLG').textContent.trim();
211+
const rows = document.querySelectorAll('.ps_grid-row');
212+
const subjectTitle = document.getElementById('SSR_CRSE_INFO_V_COURSE_TITLE_LONG')?.textContent.trim() || '';
213+
const subjectCode = document.getElementById('SSR_CRSE_INFO_V_SSS_SUBJ_CATLG')?.textContent.trim() || '';
216214
const dataset = { title: subjectTitle, code: subjectCode, class: [] };
217215

218-
// tr
219216
rows.forEach((row) => {
220217
const class_ = {};
221-
const option = row.querySelector('.OPTION_NSFF a').textContent.trim();
222-
const status = row.querySelector('.ps_box-value').textContent.trim();
223-
const psc_disabled = row.classList.contains('psc_disabled') ? '1' : '0';
224-
225-
const classElements = row.querySelectorAll('.CMPNT_CLASS_NBR a.ps-link');
226-
const seatsElements = row.querySelectorAll('.SEATS span.ps_box-value');
227-
const dayTimeElements = row.querySelectorAll('.DAYS_TIMES .ps_box-longedit');
228-
const roomElements = row.querySelectorAll('.ROOM .ps_box-edit');
229-
const instructorElements = row.querySelectorAll('.INSTRUCTOR .ps_box-longedit') || [];
230-
231-
// class
232-
const classes = Array.from(classElements).map((el, index) => {
233-
const classText = el.textContent.trim();
234-
const seats = seatsElements[index].innerText
235-
.trim()
236-
.split(' ')
237-
.filter((char) => !isNaN(parseInt(char)))
238-
.join(' ');
239-
const misc = [];
240-
241-
// Bundle misc details (day, time, instructor, room)
242-
if (dayTimeElements[index]) {
243-
const daytimeSpans = dayTimeElements[index].querySelectorAll('span');
244-
const roomSpans = roomElements[index].querySelectorAll('span');
245-
const instructorSpans = instructorElements[index]?.querySelectorAll('span') || [];
246-
247-
daytimeSpans.forEach((span, index_) => {
248-
const [day, time] = parseDayAndTime(span.innerHTML.trim());
249-
const room = roomSpans[index_].innerText.trim();
250-
const instructor = instructorSpans[index_]?.innerText.trim() || 'no_instructor_displayed';
251-
misc.push({ day, time, room, instructor });
252-
});
253-
}
254-
255-
return { classText, seats, misc };
256-
});
257-
258-
class_.option = option;
259-
class_.status = status;
260-
class_.classes = classes;
261-
262-
// For displaying options later on in 'timetable.html'
263-
class_.psc_disabled = psc_disabled;
218+
// Option number
219+
class_.option = row.querySelector('.OPTION_NSFF a')?.textContent.trim() || '';
220+
// Status
221+
class_.status = row.querySelector('td:nth-child(2) .ps_box-value')?.textContent.trim() || '';
222+
// Session
223+
class_.session = row.querySelector('.SESSION .ps_box-value')?.textContent.trim() || '';
224+
// Disabled
225+
class_.psc_disabled = row.classList.contains('psc_disabled') ? '1' : '0';
226+
227+
// All parallel arrays
228+
const classLinks = row.querySelectorAll('.CMPNT_CLASS_NBR a.ps-link');
229+
const dateSpans = row.querySelectorAll('.DATES .ps_box-value');
230+
const dayTimeSpans = row.querySelectorAll('.DAYS_TIMES .ps_box-value');
231+
const roomSpans = row.querySelectorAll('.ROOM .ps_box-value');
232+
const instructorSpans = row.querySelectorAll('.INSTRUCTOR .ps_box-value');
233+
const seatSpans = row.querySelectorAll('.SEATS .ps_box-value');
234+
235+
class_.classes = Array.from(classLinks).map((el, idx) => ({
236+
classText: el.textContent.trim(),
237+
dates: dateSpans[idx]?.textContent.trim() || '',
238+
dayTime: dayTimeSpans[idx]?.innerHTML.trim() || '',
239+
room: roomSpans[idx]?.textContent.trim() || '',
240+
instructor: instructorSpans[idx]?.textContent.trim() || 'no_instructor_displayed',
241+
seats: seatSpans[idx]?.textContent.trim() || '',
242+
misc: (() => {
243+
// For compatibility with old structure
244+
const [day, time] = parseDayAndTime(dayTimeSpans[idx]?.innerHTML.trim() || '');
245+
return [{ day, time, room: roomSpans[idx]?.textContent.trim() || '', instructor: instructorSpans[idx]?.textContent.trim() || 'no_instructor_displayed' }];
246+
})(),
247+
}));
264248

265249
dataset.class.push(class_);
266250
});

SassyNic-Student/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"author": "leeweixuan39@gmail.com",
44
"name": "SassyNic - Student",
5-
"version": "3.4.4",
5+
"version": "3.4.5",
66
"description": "Extract class details from CliC, generate possible timetable combinations and auto enrollment.",
77
"permissions": ["activeTab", "scripting", "storage", "windows"],
88
"icons": {

0 commit comments

Comments
 (0)