Last active
January 6, 2016 12:56
-
-
Save eduardocardoso/99d970801a3879ba853d to your computer and use it in GitHub Desktop.
Script to download all images from facebook comments
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
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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update the query to:
var imgs = document.querySelectorAll('div.mvs a[ajaxify]');