Last active
July 17, 2018 21:30
-
-
Save arieljannai/2b9a99ba640f1bc70b609d80ead2356f to your computer and use it in GitHub Desktop.
Shitty mass archiving Facebook messenger conversations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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