Skip to content

Instantly share code, notes, and snippets.

@4cyc
Last active January 4, 2023 09:57
Show Gist options
  • Save 4cyc/98267aee8aa378549a20f69698ef04c5 to your computer and use it in GitHub Desktop.
Save 4cyc/98267aee8aa378549a20f69698ef04c5 to your computer and use it in GitHub Desktop.
bookmarklet to refresh Gmail POP3 accounts
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);
})();
@CholoTook
Copy link

Perfect!

Thank you so much!

BTW, in FF, I pasted the formatted (raw) code into the URL box and it worked fine (e.g. no need to reformat).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment