function archive_all(testOnly) { var someMessages, archiveButton; if (testOnly === "undefined") { testOnly = false; } someMessages = $("li._k- span.accessible_elem"); console.log("Found", someMessages.length, "messages to archive in your inbox."); archiveButton = null; someMessages.each(function () { if (testOnly) { console.log("*DEBUG Only* Archived:", $(this).text()); } else { archiveButton = $(this).parent().parent().parent().prev().children()[1]; archiveButton.click(); } }); if (!testOnly) { location.reload(); } }