Skip to content

Instantly share code, notes, and snippets.

@lyndsysimon
Created July 29, 2020 16:35
Show Gist options
  • Select an option

  • Save lyndsysimon/e6a4a1becaddf09fe02c503793b545d6 to your computer and use it in GitHub Desktop.

Select an option

Save lyndsysimon/e6a4a1becaddf09fe02c503793b545d6 to your computer and use it in GitHub Desktop.
Protonmail inbox cleaner
/* Lyndsy's Protonmail mass archiver
*
* This is a simple script that marks all emails in a folder as
* read and archives them.
*
* I wrote it to work against the Protonmail Beta interface:
* https://beta.protonmail.com
*
* Usage:
* - Navigate to your inbox (or another folder, presumably)
* - Open your browser's developer tools' Javascript console
* - Paste in this script
* - Go get a cup of coffee; or maybe just go to bed if you have
* as many unread emails as I did :)
*/
let markAsRead = function() { $('a.pm-group-button')[0].click() };
let selectAll = function() { $("#selectAll").click() };
let archive = function() { $('button[data-action=archive]').click() };
function markAsReadAndArchive() {
selectAll();
setTimeout(markAsRead, 1000);
setTimeout(archive, 3000);
}
setInterval(markAsReadAndArchive, 10000);
@t2na

t2na commented Jun 10, 2021

Copy link
Copy Markdown

I'm unfortunately getting error messages trying to run this with chromium. Thanks for making it though.

@t2na

t2na commented Jun 10, 2021

Copy link
Copy Markdown

Uncaught ReferenceError: $ is not defined
at selectAll (:2:30)
at markAsReadAndArchive (:6:3)
at r (helpers.ts:87)
selectAll @ VM79:2
markAsReadAndArchive @ VM79:6
r @ helpers.ts:87
setInterval (async)
(anonymous) @ trycatch.ts:119
(anonymous) @ VM79:11
instrument.ts:158 POST https://mail.protonmail.com/api/reports/sentry/api/9/store/?sentry_key=64982c67a00b4e68833169e2c4f26819&sentry_version=7 net::ERR_BLOCKED_BY_CLIENT

@apazzy

apazzy commented Jan 23, 2022

Copy link
Copy Markdown

EDIT: Removed code in this comment, forked and updated the scripts here: https://gist.github.com/apazzy/33af2c32e066ae8e6c0a9c224ebdf72b

@lyndsysimon

Copy link
Copy Markdown
Author

@apazzy Thank you!

Sorry for the very late reply; I no longer regularly use GitHub. My employer uses Gitlab for their projects, and I've migrated my active stuff to Sourcehut.

@torak2000

Copy link
Copy Markdown

More elegant way — I went through the same pain and found a desktop app that actually solves this properly: archiver.email

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