Forked from theJohnnyBrown/download_facebook_tagged_photos_2022.js
Last active
October 13, 2025 02:47
-
-
Save flightmansam/e84c39977c206b1706c54c5270425701 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Navigate to https://facebook.com/MY_PROFILE/photos_of | |
| // Paste this code, it will download each image and click "next" then download the next one | |
| // The delays are to avoid being blocked by facebook | |
| // If it hits an error you can restart by calling download(300) again (or whatever number) | |
| async function downloadImage(imageSrc) { | |
| const image = await fetch(imageSrc); | |
| const imageBlog = await image.blob(); | |
| const imageURL = URL.createObjectURL(imageBlog); | |
| const link = document.createElement('a'); | |
| link.href = imageURL; | |
| const fbid = new URLSearchParams(window.location.search).get("fbid") | |
| link.download = fbid + ".jpg"; | |
| document.body.appendChild(link); | |
| link.click(); | |
| document.body.removeChild(link); | |
| } | |
| function imageSrc() { | |
| return document.querySelector('[data-visualcompletion="media-vc-image"]').src; | |
| } | |
| function sleep(ms) { | |
| return new Promise(resolve => setTimeout(resolve, ms)); | |
| } | |
| async function download(numberOfPhotos) { | |
| for (let i = 0; i < numberOfPhotos; i++) { | |
| await downloadImage(imageSrc()) | |
| await sleep(1500); | |
| document.querySelector('[aria-label="Next photo"]').click(); | |
| await sleep(200); | |
| } | |
| console.log('Done'); | |
| } | |
| NUMBER_OF_PHOTOS = 300; | |
| download(NUMBER_OF_PHOTOS); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment