solymosi / npu

Neptun PowerUp! - Felturbózza a Neptun-odat
MIT License
274 stars 47 forks source link

I wrote a script to mark all mails as read if I press a button in the menu., if it helps, include it in #43

Closed FeaXR closed 1 year ago

FeaXR commented 4 years ago

// ==UserScript== // @name Neptun New Messages Auto Read // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world, or just read the messages. // @author Krachi9 // @match https://frame.neptun.bme.hu/hallgatoi/main.aspx?ismenuclick=true&ctrl=inbox // @grant none // ==/UserScript==

(function() { 'use strict'; var read = $(''); $("#function_delete0").after(read); var scriptElem = document.createElement('script'); scriptElem.innerHTML = 'function readAll(){var newMessages = document.getElementsByClassName("Row1_Bold");for(var i =0; i < newMessages.length; i++){var link = newMessages[i].getElementsByClassName("link");link[0].click();var backButton = document.getElementsByClassName("ui-button");for(var j = 0; j < backButton.lenght; j++){if(backButton[i].value == "Vissza"){backButton[i].click();}}}}'; document.body.appendChild(scriptElem); })();

FeaXR commented 4 years ago

If you paste this code at the bottom of NPU right after the npu.init() line it will work.

var read = $(''); $("#function_delete0").after(read); var scriptElem = document.createElement('script'); scriptElem.innerHTML = 'function readAll(){var newMessages = document.getElementsByClassName("Row1_Bold");for(var i =0; i < newMessages.length; i++){var link = newMessages[i].getElementsByClassName("link");link[0].click();var backButton = document.getElementsByClassName("ui-button");for(var j = 0; j < backButton.lenght; j++){if(backButton[i].value == "Vissza"){backButton[i].click();}}}}'; document.body.appendChild(scriptElem);

DanShepherd27 commented 4 years ago

I tried to include it in the PowerUp code for myself, but it does not seem to work for me. Where should the button show up? I don't know if it's normal to see warnings next to the first two lines of your code "eslint: no-undef - '$' is not defined.". The problem is that I haven't learned js whatsoever, so I don't know where the issue might come from.

FeaXR commented 4 years ago

It should be displayed at the messages section, right nex to the delete button. I made a separate script for it, feel free to try this one if it works: https://github.com/krachi9/NeptunMessageReader

I could only test it at BME and ELTE but is tshould work on other sites as well.

solymosi commented 4 years ago

Thanks for this - let me see if I can add it to the official version 😉

FeaXR commented 4 years ago

Thanks for this - let me see if I can add it to the official version 😉

I found that if there is an official letter and I skipped it with npu, then read it with my script, the neptun system doesn't recongise that I have read it and the message is still popping up prompting me to read it, though the letter itself is marked as read, since it doesn't appear in bold

solymosi commented 4 years ago

I found that if there is an official letter and I skipped it with npu, then read it with my script, the neptun system doesn't recongise that I have read it and the message is still popping up prompting me to read it, though the letter itself is marked as read, since it doesn't appear in bold

Yep, Neptun sometimes often acts in retarded ways thanks to the way ASP.NET Web Forms based apps work (e.g. last time I checked things tend to break if you have Neptun open in more than one tab and do different things in them). Since normally you aren't allowed to do anything before reading the official letter, marking it as read before reading it is supposed to be impossible, so they understandably haven't implemented the logic that stops the nagging popup in that case.

I don't know how we could fix this other than the "nuclear" approach, i.e. clearing the view state (which I wouldn't like to do as it could break something important).

FeaXR commented 4 years ago

I found that if there is an official letter and I skipped it with npu, then read it with my script, the neptun system doesn't recongise that I have read it and the message is still popping up prompting me to read it, though the letter itself is marked as read, since it doesn't appear in bold

Yep, Neptun ~sometimes~ often acts in retarded ways thanks to the way ASP.NET Web Forms based apps work (e.g. last time I checked things tend to break if you have Neptun open in more than one tab and do different things in them). Since normally you aren't allowed to do anything before reading the official letter, marking it as read before reading it is supposed to be impossible, so they understandably haven't implemented the logic that stops the nagging popup in that case.

I don't know how we could fix this other than the "nuclear" approach, i.e. clearing the view state (which I wouldn't like to do as it could break something important).

My thought was that if npu detects that there is that popup, it opens the letter and closes it, so they'll be marked as read.

Also I'm not sure about my closing the letter method, since it takes a fair amount of time for Neptun to open up the letter so JS scans too early for the button, but it's not an issue with non-official letters, since they'll be marked as read in the messaging section upon opening them. I messed around a bit with an official letter but now I don't have any more left so I can't test it, but I found that they are marked as read when they are closed, not when whey are opened, so either I'll have to manually open and close them, or find a way to work around the lag of opening the letter.

FeaXR commented 4 years ago

Or... Official letters are not so numerous and in most of the cases they should be read, so maybe it's not even a bad thing to remind the user of an unread official message. And that's how you present a bug as a feature

isti115 commented 4 years ago

@krachi9 Even if they are important (which many time they aren't really, they are just marked so... sometimes even accidentally being sent to me), the problem for me is that they are automatically forwarded as emails as well, so when I don't log in for a while (because I usually don't have any reason for doing so during the semesters), I am greeted with around >30 of them. If you combine that with the amazing speed of Neptun in terms of loading the following one when I click the next button, it can lead to frustrating minutes of clicking, which, even worse on a touchscreen, sometimes turns into random zooming gestures as well... Also, let's not forget that the size of the message window can also depend on the length of the content, so in certain cases I even need to go hunting for the next button... :upside_down_face:

Also, @solymosi I can definitely confirm that having multiple Neptun tabs open leads to inevitable chaos, once I had to recalculate a bunch of grades for students, because I was stupid enough to try and enter them for multiple groups simultaneously (since in the system, where they completed their tasks, they were not separated by the course numbers they have signed up for), and the system only managed to store one of them, so I had to sum up the done tasks of the others once again...

ps.: @krachi9 If you are a student at ELTE, I think that I can send you as many official letters as you'd like for testing. I don't exactly know what makes a message official, but just tried sending one to myself, and it appeared as an unread official message ("olvasatlan hivatalos üzenet"). Maybe it's enough, if it's coming from someone, who's logged into the teacher interface.

FeaXR commented 4 years ago

@Isti115 That's true, I haven't thought of that, because I have to log in quite frequently because of the exams or other things. Unfortunately I'm not a student of ELTE, but thanks a lot :)

whisperity commented 4 years ago

ps.: @krachi9 If you are a student at ELTE, I think that I can send you as many official letters as you'd like for testing. I don't exactly know what makes a message official, but just tried sending one to myself, and it appeared as an unread official message ("olvasatlan hivatalos üzenet"). Maybe it's enough, if it's coming from someone, who's logged into the teacher interface.

@Isti115 Messages sent from the teacher or the administrative client interface are considered as "official message" when viewed from the student page. Logging into the teacher page while having an "official message" does not produce a pop-up. 😁

I've just checked, even if from the teacher page I send a mail directly to someone by typing in their ID (as opposed to sending a broadcast mail to a group, subject, curriculum, faculty, etc., so anything that sends mail in bulk automatically to a set of people...) still counts as "official message"... even if you send the message to yourself.

This is definitely valid for ELTE.

whisperity commented 4 years ago

You have to open the mail from the "You have official mail" pop-up, where you have no choice but only to close after you've read the message: image

This action seems to count as registering the read on the official mail. 😯

If you open it from the mail list where you have these 5-ish options: image

It does NOT count as having read the official mail. But it does count as having read the mail, i.e. it'll be unbolded. See: image

whisperity commented 4 years ago

if(backButton[i].value == "Vissza")

I would prefer if we at least tangentially supported the official translations present in Neptun, i.e. made NPU work with at least the English (but I think ELTE has German, and BME also has French in addition!) interface.

FeaXR commented 4 years ago

@whisperity Thanks, I totally forgot about multi-language, but the actual implementation was about 20 seconds. https://github.com/krachi9/NeptunMessageReader/

solymosi commented 1 year ago

Since this doesn't seem to stop the annoying popups I'll close the PR for now. If we can find a solution to the issue I'm happy to revisit the topic.