Last active
September 25, 2021 16:31
-
-
Save jatinkrmalik/d45a29d33eb14d412c3e482851f2441b to your computer and use it in GitHub Desktop.
Bulk archive old facebook posts
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
// Bulk archive old facebook posts | |
// Writen by: @jatinkrmalik | |
// # Usage guide: | |
// 1. Open https://www.facebook.com/<your_user_id>/allactivity/ | |
// 2. Click on "Manage activity" in the left panel. | |
// 3. Make sure "Your posts" is selected. | |
// 4. Execute the script in dev console. | |
// 5. ??? | |
// 6. PROFIT! | |
// archive btn | |
archiveBtn = $("div[aria-label='Archive']") | |
// utlity func to sleep for duration | |
function sleepFor(sleepDuration){ | |
var now = new Date().getTime(); | |
while(new Date().getTime() < now + sleepDuration){ | |
console.log("Sleeping for duration: ", sleepDuration) | |
} | |
} | |
function scrollAndArchive() { | |
// flg for 5 scrolls | |
flg = 0 | |
while(true){ // infinity loopity | |
if (flg > 5) { | |
console.log("select all posts // flag: ", flg) | |
document.querySelectorAll("div.d46ut3hm input").forEach(el => el.click()); | |
archiveBtn.click(); | |
console.log("click archive btn") | |
flg = 0 | |
} | |
flg = flg + 1 | |
sleepFor(10000); // slow graphql apis | |
console.log("scrolling to the end of the page // flag: ", flg) | |
window.scroll(0, document.body.scrollHeight); // scroll to end | |
sleepFor(10000); // slow graphql apis | |
} | |
} | |
// start | |
scrollAndArchive() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment