Last active
March 3, 2025 07:51
-
-
Save SMUsamaShah/dfcc6f709158b0adcc0a48c2d66fd353 to your computer and use it in GitHub Desktop.
Gmail sort by sender bookmarklet (drag the code to bookmark bar)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(function() { | |
| function sortEmailsBySender() { | |
| var emails = Array.from(document.querySelectorAll('.zA')); | |
| emails.sort(function(a, b) { | |
| var senderA = a.querySelector('.yW span').innerText.toLowerCase(); | |
| var senderB = b.querySelector('.yW span').innerText.toLowerCase(); | |
| return senderA.localeCompare(senderB); | |
| }); | |
| emails.forEach(function(email) { | |
| email.parentNode.appendChild(email); | |
| }); | |
| } | |
| sortEmailsBySender(); | |
| })(); |
Author
@shadsnz Did you remove all the comments when using it as bookmarklet?
Yes, I did. I'm using Chrome, have tested in both the Gmail Inbox, Sent and All Mail folders. I might try a different browser and another Gmail account to test.
Well, it seems to work sometimes now after refreshing browsers and increasing the number of messages per page. Thanks for posting the code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi SMUsamaShah,
I'm trying to run this but it doesn't seem to sort the emails. I tested the very first version and it does sort but when you open the email its the original message from that position.
So these newer versions are obviously better but don't seem to work for me. I checked the console messages and it does seem to be triggering but doesn't change the emails shown.
Any suggestions on what I might have missed?
Thanks