Created
August 11, 2018 13:39
-
-
Save rosenpin/a00cf5f2bfac8d589e5790faa896b2ca to your computer and use it in GitHub Desktop.
Delete all emails in an open folder in Protonmail
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
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
async function deleteAllMails(){ | |
for (var i = 0;i<100;i++){ | |
setTimeout(function(){document.getElementById("selectAll").click()},1000); | |
setTimeout(function(){document.getElementsByClassName("moveElement-btn-delete")[0].click()},3000); | |
setTimeout(function(){document.getElementById("confirmModalBtn").click()},5000); | |
await sleep(10000) | |
} | |
} | |
deleteAllMails() |
This latest code will delete based on current webmail
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function getTotalEmailPages(){
document.querySelectorAll('[data-testid="toolbar:page-number-dropdown"]')[0].click();
let returnvalue = document.getElementsByClassName("dropdown dropdown--bottom toolbar-dropdown no-outline")[0].getElementsByTagName("ul")[0].getElementsByTagName("li").length;
document.querySelectorAll('[data-testid="toolbar:page-number-dropdown"]')[0].click();
console.log(`total pages remaining - ${returnvalue}`);
return returnvalue;
}
async function deleteAllMails(){
while(getTotalEmailPages() > 0){
setTimeout(function(){document.getElementById("idSelectAll").click()},1000);
setTimeout(function(){document.querySelectorAll('[data-testid="toolbar:movetotrash"]')[0].click()},3000);
setTimeout(function(){document.querySelectorAll('[data-testid="filter-dropdown:show-read"]')[0].click()},6000);
setTimeout(function(){document.querySelectorAll('[data-testid="filter-dropdown:show-all"]')[0].click()},9000);
await sleep(12000);
}
}
deleteAllMails();
+1 @pavanbuzz
If you end up like me stuck with messages in All mail, but no other folder, you can use the following to delete:
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function deleteAllMails(){
for (var i = 0;i<100;i++){
setTimeout(function(){document.getElementById("idSelectAll").click()},500);
setTimeout(function(){document.querySelectorAll('[data-testid="toolbar:movetotrash"]')[0].click()},1000);
setTimeout(function(){document.querySelectorAll('[data-testid="toolbar:next-page"]')[0].click()},1500);
await sleep(5000);
}
}
deleteAllMails();
Instead of selecting all, deleting and then refreshing, this will select all, delete and then move forward a page.
This gets around the fact that the All mail folder includes messages already in trash.
I also couldn't get @pavanbuzz's getTotalEmailPages to work. I had 3000 pages but never really dove into why it was failing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would this have changed at all, It has been handy!