Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify unread messages with more reability #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JCKodel
Copy link

@JCKodel JCKodel commented Mar 3, 2021

Change way of determining unread badges from Whatsapp.

Whatsapp uses generated class names, so very often they change and then the recipe stops working.

What I did was to find all spans with aria-label attribute (there are 3 of them: the "your phone is low on battery" close button, the "mark as unread" badge (the badge without a counter) and the threads with unread counters.

The difference between those spans is that only the unread badges has background-color: var(--unread-marker-background);.

I could not find a way to read the var(--unread-marker-background) from JS, so I get the color from both light and dark theme and using them to find the unread badges.

Finally, I try to parse the contents of the badge (for example: in portuguese, when a badge have (1), the aria-label is "1 mensagem não lida").

So I add that parse + 1 for each "marked as unread" (which have no counter nor aria-label content) and voi-la. A reliable counter that don't depend on Whatsapp class names anymore.

Change way of determining unread badges from Whatsapp
@speakthinker
Copy link

speakthinker commented Mar 4, 2021

Thanks for the solutions Actually worked for me and the notifications are back.
(First comment ever here on Git, but thought to leave a small thank you message here.)

@JCKodel
Copy link
Author

JCKodel commented Mar 4, 2021

Added fix for full width on thread list and status list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants