Skip to content

Instantly share code, notes, and snippets.

@ErykDarnowski
Last active November 5, 2023 18:44
Show Gist options
  • Save ErykDarnowski/c0d697e69d13e8c1cad8da9bf947e832 to your computer and use it in GitHub Desktop.
Save ErykDarnowski/c0d697e69d13e8c1cad8da9bf947e832 to your computer and use it in GitHub Desktop.
USOS print out unique lesson names (part time)
/*
!!! THIS WAS JUST A PROTOTYPE, HERE IS THE MUCH BETTER, IMPROVED VERSION: !!!
https://gist.github.com/ErykDarnowski/fd08f94ca139b1f575d8e7205e2e3a90
*/
/* USOS print out unique lesson names (part time)
* !!!This was created for the part time timetable as it doesn't divide the lessons by days!!!
*
* 1. Open your uni's USOS page
* 2. Go to your lesson timetable
* 3. Open the dev tools (F12)
* 4. Click the `Console` tab
* 5. Paste in the script, press Enter
* 6. Copy the printed result!
*/
const ignoreList = ['Wstęp do programowania']; // here you can put names of subjects (without the building + class information in parenthesis) that you'd like for the script to not display (ignore - if you've for instance passed them already)
const classroomNumRegex = new RegExp(' \\(.*');
const lessonNames = $x('//*[@id="layout-c22"]/div/div[3]/div/div[2]/table/tbody/tr/td/div').map(el => el.textContent.replace(classroomNumRegex, ''));
const lessonNamesUniq = Array.from(new Set(lessonNames));
let count = 1;
let finalListStr = '';
lessonNamesUniq.map(name => (!ignoreList.includes(name)) && (finalListStr += `${count++}. ${name}\n`));
console.log(finalListStr); // so you can copy it from the dev console in a clear way (instead of printing line by line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment