[NEW FEATURE]: Automatically open all stared courses
Suggestion
For me it would be very useful to automatically open all my starred courses every time I visit Opal.
So instead of seeing this when opening Opal:
I would like to see this:
Why?
Because often when I open Opal I want to check multiple things, and this makes switching between my courses so much faster as I don't even have to click on the TUFast extension anymore. Having the tabs with open courses is a builtin feature of Opal and it perfectly solves my problem, it is just annoying that I have to open them all individually every time.
Downsides
Right now I cannot think of any downsides that this feature would have, it might require to refresh the page once all the opening requests are made, but those 200ms is a well worth sacrifice, at least for me.
Technical details
Opening up a course can be done through sending a GET request to /opal/auth/RepositoryEntry/${courseId}. As TUFast already knows all my starred courses, implementing this wouldn't be hard. It would just require a simple toggle switch in the settings.
I think I could implement this on my own and open up a PR when I'm ready but I just wanted to check before doing all the work
Thanks for the comprehensive explanation. I think I understand your issue.
It sounds perfectly sensible to me to implement this. The technical solution you propose seems also valid to me.
Two things that come to my mind that might be worth checking are:
- [ ] Does Opal close all the tabs by default when logging out? (Otherwise you would spam tabs.)
- [ ] As a security measure, only open the first "X" favorites as tabs, otherwise it might crash the page if someone has 100 favs.
As I think you already mentioned, it would be an optional setting, as users might not want it and it prolongs page load time. (It could be activated by default though for new installs, as of my opinion.)
The feature itself would be implemented in the "Opal content script", I think. If you have any questions, feel free to post them here.
Opal does indeed close all tabs when logging out, I tried to find out if there is a way to change this default behavior but my search on the Opal documentation did not yield any results.
The second point of not opening too many tabs is a very valid concern, I will take that into consideration.
My current plan is to add a script to the src/contentScripts/other/opal folder and then add it as a https://bildungsportal.sachsen.de/opal/* matching script. As it only makes sense to do these requests when the user is already logged in I am wondering how to check that. Is it viable to check for the authenticated-marker cookie or what is the preferred way to check if a user is logged in or not?
Your idea sounds good. Site checking is a bit messy. Using your suggested cookie is definetely fine if it works, i.e. it might even be better than the methods we are currently using.
Here we are using the window.location.pathname to check if we are on a certain page. (Might not be applicable to this issue.) Here we are checking if a certain DOM-Element exists using optional chaining to determine the injection of a tag. (Props to @C0ntroller for using that syntax.)