Last active
January 4, 2023 09:57
-
-
Save 4cyc/98267aee8aa378549a20f69698ef04c5 to your computer and use it in GitHub Desktop.
bookmarklet to refresh Gmail POP3 accounts
This file contains 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 () { | |
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); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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).