Created
June 15, 2018 04:41
-
-
Save rbreaves/85bf802b46c7ab256b475087f879336a to your computer and use it in GitHub Desktop.
Unread Count on the Left in Gmail
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
| // ==UserScript== | |
| // @name Relocate Unread Count for Gmail | |
| // @namespace http://elomental.com/ | |
| // @version 1.0 | |
| // @description Relocate the unread count to the left for Gmail labels | |
| // @author Ryan Reaves | |
| // @match https://mail.google.com/* | |
| // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js | |
| // @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
| // @grant none | |
| // ==/UserScript== | |
| waitForKeyElements (".nM", actionFunction); | |
| function actionFunction () { | |
| var all = $(".J-Ke").map(function() { | |
| if (this.innerHTML.charAt(0) != "("){ | |
| var unreadCount = "(" + this.innerHTML.split("(").pop().trim(); | |
| var label = this.innerHTML.split("(").shift().trim(); | |
| if (unreadCount.substr(unreadCount.length - 1) == ")") { | |
| this.innerHTML = unreadCount + " " + label | |
| } | |
| } | |
| return this.innerHTML; | |
| }).get(); | |
| } | |
| var i = setInterval(actionFunction,5000); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A few of my gmail labels got to be a little long and it obscured my unread count for some labels, making it difficult to gauge how many and whether I had new emails that I needed to looked at. This script fixes that by immediately loading once the labels are on the page and modifying the DOM, and it also rechecks every 5 seconds to make sure that the unread counts stay on the left side.