Easily refresh all your POP3 E-Mail accounts linked to Gmail with a bookmarklet

Refresh Gmail POP3 accounts
Updated: November 22, 2022 Published:  December 8, 2021

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.

Gmail dummy refresh button
dummy Gmail refresh button

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.

manually refresh accounts
Manually refresh email accounts

The bookmarklet to check all mail accounts with 1 click

Let’s solve this with a simple bookmarklet! A bookmarklet is JavaScript code saved as a bookmark, which can be run with a single click.

Here is the code, I’m going to explain it later.

What the email bookmarklet does

  1. 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.
  2. It will then automatically navigate to your Gmail Settings.
  3. 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.
  4. 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.
  5. 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

You cannot simply copy the JavaScript code, it needs to have some adjustment: No line breaks or single-line comments are allowed and you have to put a ‘javascript: ‘ at the beginning. Here you’ll find a way to quickly get rid of your line breaks.

The final bookmarklet for Gmail

Here is the code of the bookmarklet without line breaks:

javascript: (function () { const gmailWindow = window; if(gmailWindow.location.href.indexOf("https://mail.google.com/") === -1){ alert('You have to run the bookmarklet from a Gmail window'); return; } gmailWindow.location.assign('https://mail.google.com/mail/u/0/#settings/accounts'); const xpath = "//span[text()='Check mail now']"; const refreshAccounts = () => { const selectedNodeElements = gmailWindow.document.evaluate(xpath, gmailWindow.document, null, XPathResult.ANY_TYPE, null); let currentNode = selectedNodeElements.iterateNext(); if (currentNode === null) { setTimeout(refreshAccounts, 100); } else { while (currentNode) { currentNode.click(); currentNode = selectedNodeElements.iterateNext(); }; gmailWindow.location.assign('https://mail.google.com/mail/u/0/#inbox'); }; }; setTimeout(refreshAccounts, 100); })();

The only thing you have to do is to insert the JavaScript code as the URL of a bookmark and you now have a bookmarklet.

add bookmarklet to browser
Create bookmarklet

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']";



  1. That’s brilliant…. thanks. Not really familiar with javascript but this works fine.
    Only snag is that I normally have 2 gmail accounts open on the top tabs and this works for my account but for my wife’s it opens up my account on her tab, and sticks at the ‘settings’ page. Any ideas?

    1. I think you have to adjust the bookmarklet, the same way you have to modify it a bit if you’re using Gmail in a different language. In the bookmarklet there’s an URL to access the settings and “press” the check new e-mail link without your intervention, it’s “https://mail.google.com/mail/u/0/#settings/accounts”. If you’re using several accounts, they are identified by the number after “/u/”. For example, your Gmail account might be “/u/1” and your wife’s could be “/u/0”, that’s why it tries to run on that account and not yours.

      Please note that this number is not fixed, it’s defined by who login first (first account to login to Gmail in the browser is set to “0”, next one is “1”, and so on) and you might end needing to edit the bookmarklet from time to time if this changes.

      I’m sure that the bookmarklet could check the id of the account from the current window’s URL and change the gmailWindow.location.assign link accordingly, but I’m not familiar enough with JS to implement it.

  2. Great! Could it be stuck in a button within gmail using grease monkey? Could it report back the number of fetched mails?


Leave a comment

Your email address will not be published. Required fields are marked *