Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save elibosley/6acb8850ad1f9f208c30d7c7e2842b89 to your computer and use it in GitHub Desktop.
Save elibosley/6acb8850ad1f9f208c30d7c7e2842b89 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.

UPDATE: THIS SCRIPT HAS BEEN UPDATED TO WORK AND IS TESTED AS WORKING (OCTOBER 31st, 2017 (spooky)). LET ME KNOW IF IT DOESN'T WORK FOR YOU!

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. (Maybe)
  • 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) {
messages = $("._5blh")
console.log("Found", messages.length, "messages on messsenger.");
if (!testOnly) {
for (i = 0; i < messages.length; i++) {
try {
messages[i].click()// open dialog
$("li:contains('Archive')").last().click()
}
catch (TypeError) {
console.log("TypeError")
}
}
}
}
@szczepkacpra
Copy link

Try this one again, it should work.
I just tried today and it is working perfectly.

Thanks for answering. You sent me the same codes I have tried and quoted in my question.

Did you use top or the bottom code?
Did you go to facebook.com/messages or messenger.com?
What browser are you using?

@surajk63
Copy link

Try this one again, it should work.
I just tried today and it is working perfectly.

Thanks for answering. You sent me the same codes I have tried and quoted in my question.

Did you use top or the bottom code?
Did you go to facebook.com/messages or messenger.com?
What browser are you using?

I used the second code, first you have to load jquery code and then this function.
Then you can call the function as many times as you required.
You can try on both link: facebook.com/messages or messenger.com on chrome latest browser.

Thanks
-Suraj

@szczepkacpra
Copy link

szczepkacpra commented Apr 20, 2020

I found the solution: Facebook language has to be set to English. Otherwise the script won't work.

Thanks for getting involved @surajk63

@elibosley could you please include this information in your description?

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