Skip to content

Instantly share code, notes, and snippets.

@arieljannai
Last active July 17, 2018 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arieljannai/2b9a99ba640f1bc70b609d80ead2356f to your computer and use it in GitHub Desktop.
Save arieljannai/2b9a99ba640f1bc70b609d80ead2356f to your computer and use it in GitHub Desktop.
Shitty mass archiving Facebook messenger conversations
// 1. Open https://www.messenger.com/
// 2. Scroll to the bottom until all converstations are loaded, and run this from the console.
var converstaionsNumber = document.querySelectorAll('[aria-label="Conversation actions"]').length - 1;
function archiveLast() {
document.querySelectorAll('[aria-label="Conversation actions"]')[converstaionsNumber--].click();
setTimeout(function() {
var button = document.getElementsByClassName('_54nh')[1];
if (button.textContent != "Archive") {
button = document.getElementsByClassName('_54nh')[2];
}
button.click();
}, 5);
if (converstaionsNumber >= 0) {
setTimeout(archiveLast, 5);
}
}
// Note: I started from the bottom because I wanted to keep the newest/active chats, so I just existed the page when arrived to that point.
// You can stop a second before, and do the last 1-2 manually, or with the same function (but remove the recursive call!)
// TODO:
// * Auto scroll to the bottom
// * Set a number of chats to leave unchanged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment