A missing feature in Gmail is that you cannot refresh your linked email accounts conveniently. It seems to bother the community as you can see here and here on Google, and here at stack exchange. You can speculate that Google doesn’t like that feature, maybe thinking people will use their Gmail account or switch to G-Suit aka Google Workplace. Anyways, this shouldn’t be the topic here.
The current state with Gmail
The way Google is calculating the interval to check on your mail accounts is depending on how often you receive an email. This technique is especially not helpful when you are waiting for e.g. a signup confirmation email. Some resources stating a click on the refresh icon will trigger your accounts to get refreshed. A quick check on the settings page shows that it’s more like a dummy and doesn’t refresh POP3 mail accounts.
An effective way of retrieving your emails is through “Settings” → “Accounts and Import” → “Check email from other accounts”-section and clicking on “Check mail now”.However, this is a tedious and annoying process that screams for automatization.
The bookmarklet to check all mail accounts with 1 click
Here is the code, I’m going to explain it later.
What the email bookmarklet does
- Due to security reasons (CORS) you have to run the bookmarklet from your Gmail tab. Therefore, the bookmarklet will first check if you’re in the right window. In my case I always have the Gmail window pinned to my tab bar.
- It will then automatically navigate to your Gmail Settings.
- After 100 milliseconds it will check if the Gmail Settings have loaded completely. To do so, it will try to access the links to refresh each POP-account. This is being done through XPath since IDs and classes will change over time.
- If it can succesfully access the links, the links will get clicked and it will load the Gmail inbox again. If the page is not ready yet, it will try again after 100 milliseconds.
- Done, now your inbox with all your email accounts should be up-to-date!
(thanks to Nathan Stretch at this point for speeding up the execution time of the script!)
Attention, there is a pitfall
The final bookmarklet for Gmail
Here is the code of the bookmarklet without line breaks:
Note: Gmail takes a few seconds to refresh the inbox so you have to wait a bit after clicking the bookmarklet and refresh the inbox page (CMD/STRG + R)
Your Gmail ist set to a different language? Adjust the bookmarklet to your needs!
If you are using Gmail in a different language, you have to adjust the “Check mail now” at the following position so the script will be able to access the refresh links:
const xpath = "//span[text()='Check mail now']";