Skip to content

Instantly share code, notes, and snippets.

@eduardocardoso
Last active January 6, 2016 12:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardocardoso/99d970801a3879ba853d to your computer and use it in GitHub Desktop.
Save eduardocardoso/99d970801a3879ba853d to your computer and use it in GitHub Desktop.
Script to download all images from facebook comments
var arr = [];
var imgs = document.querySelectorAll('div.mvs a[ajaxify]');
for (var i = 0; i < imgs.length; i++) { arr.push(imgs[i]); }
var a = document.createElement('a');
var re = RegExp("[?&]src=[^&]+")
arr.forEach(function (img) {
ajaxify = img.getAttribute('ajaxify');
encoded_img_url = re.exec(ajaxify)[0].substr(5);
decoded_img_url = decodeURIComponent(encoded_img_url);
a['href'] = decoded_img_url;
a['download'] = 'img.png';
a['target'] = '_blank';
document.body.appendChild(a);
a.click();
});
@rafesc
Copy link

rafesc commented Nov 17, 2015

Update the query to:
var imgs = document.querySelectorAll('div.mvs a[ajaxify]');

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