Skip to content

Instantly share code, notes, and snippets.

@tedmiston
Last active March 31, 2026 06:07
Show Gist options
  • Select an option

  • Save tedmiston/c7ac401da96b55022aaf to your computer and use it in GitHub Desktop.

Select an option

Save tedmiston/c7ac401da96b55022aaf to your computer and use it in GitHub Desktop.
Archive all of the messages in your Facebook Messages Inbox

Facebook - Archive All Messages

Because who doesn't have an inbox full of "I got a new phone", event-based group chats, and old lingering messages in their Facebook Messages?

Surprisingly, Facebook has not implemented a way to archive many messages in your inbox. This script provides that solution.

Quickstart

Load Facebook Messages in a new tab.

Open the JavaScript console and paste the contents of jquery.min.js into the console.

Paste the contents of archive-all-facebook-messages.js into the console.

If you want to only test the results before actually running the archiving, there's a param for that:

archive_all(testOnly=true);

When you're ready to run for real:

archive_all();

Caveats

  • Currently only detects the list of messages visible to the user in the page. You can work around this by repeatedly scrolling the message list pane to the bottom until all messages are loaded. I plan to automate this step soon.
  • There is no way to whitelist certain messages from being archived. Currently, you can manually unarchive select messages from the archived view.
  • Sometimes the messages page remains cached after the script reloads it. Reloading it once by hand solves this.
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();
}
}
@capoexe
Copy link
Copy Markdown

capoexe commented Mar 31, 2026

had to make a new account for this, anyways this doesnt work anymore and what seemed to work is this, make sure you're in the "messenger.com" website and press f12 and go to the console and paste this and enter

edit: in order to stop it or if its done just type "clearInterval(the number it showed after u entered)"

setInterval(() => { let buttons = document.querySelectorAll('[role="button"]'); for (let btn of buttons) { let label = btn.getAttribute('aria-label'); if (label && label.startsWith('More options for')) { btn.click(); setTimeout(() => { document.querySelectorAll('div[role=menuitem]').forEach(item => { if (item.innerText.includes('Archive chat')) item.click(); }); }, 800); break; } } }, 1500);

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