I needed to archive tens of thousands of Hotmail e-mails after my POP3 client started to hiccup to the sheer amount of messages in the Inbox. OWA-Outlook Web Access doesn't have an option (that I know of) to archive everything in one go. So I wrote this script to do the heavy clicking. I could try IMAP but where's the fun?
The script locates the UI buttons independently of language (tested in English and Portuguese), but before starting it will show a confirmation of what operation it will perform (must be ARCHIVE). Changes will probably break it, but I'll try to keep it up to date.
Depending on screen size and network conditions, the messages pane may get empty or emails become unselectable. The script detects such conditions and refreshes the view by alternating between Junk and Inbox.
Check it in action in the video below:
Copy the script below. It must be pasted in the browser's development console (F12):
Ze script (click to select)
/* Created 2016-12-17 00h25 */ var selectAll=null; var archive=null; var inbox=null, spam=null; var lastConv=null; var x, n; var messagesPane=null; function getConv() { var ret=null; var i; var x=document.getElementsByTagName("div"); for (i=0; i < x.length; i++) if ((ret=x[i].getAttribute("data-convid"))!=null) break; return ret; } function doArchive() { if (document.readyState=="complete") { var conv=getConv(); var emptyTrophy = document.getElementsByClassName("ms-Icon--emptyTrophy").length>0; if (emptyTrophy) { alert("All archived!"); return; } if ((document.body.innerHTML.indexOf("data-convid")!=-1) && (conv!=lastConv)) { selectAll.click(); if (!archive) { archive=document.getElementsByClassName("ms-Icon--archive")[0].parentNode; if (!confirm("Selected command is " + archive.innerText.toUpperCase() + ". Proceed?")) { selectAll.click(); return; } } var selectedItems=undefined; x=document.getElementsByClassName("folderHeaderLabel"); if (x) selectedItems=x[0]; if (selectedItems!=undefined) setTimeout(function() { archive.click(); lastConv=conv; setTimeout(function() { doArchive(); }, 1000); }, 1000); else setTimeout(function() { doArchive(); }, 1000); } else { setTimeout(function() { lastConv=null; spam.click(); setTimeout(function() { inbox.click(); setTimeout(function() { doArchive(); }, 1000); }, 1000); }, 1000); } } else setTimeout(function() { doArchive(); }, 1000); }; n=0; x=document.getElementsByTagName("span"); for (i=0; i < x.length; i++) if (x[i].id && (x[i].id.indexOf(".folder")!=-1)) { if (n==1) inbox=x[i]; if (n==2) spam=x[i]; n++; if (inbox && spam) break; } x=document.getElementsByTagName("div"); for (i=0; i < x.length; i++) if ((x[i].getAttribute("role")=="region") && (x[i].innerHTML.indexOf("data-convid")!=-1)) { messagesPane=x[i]; break; } x=document.getElementsByTagName("button"); for (i=0; i < x.length; i++) if (x[i].title && messagesPane && messagesPane.contains(x[i])) { selectAll=x[i]; break; } doArchive();