Skip to content

Instantly share code, notes, and snippets.

@AdySan
Forked from yongheng/download-tadpoles-media.js
Created August 23, 2018 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdySan/047408a0aee487c2b170e22e4c66cf37 to your computer and use it in GitHub Desktop.
Save AdySan/047408a0aee487c2b170e22e4c66cf37 to your computer and use it in GitHub Desktop.
Download Tadpoles Media
// Step 1: Open https://www.tadpoles.com/parents and log in;
// Step 2: Select the 'all' tab (IMPORTANT STEP);
// Step 3: Select a month;
// Step 4: Open the JavaScript console in your browser (e.g., press
// Command + Alt + i in Google Chrome on a Mac, or press
// Ctrl + Shift + i in Google Chrome in Windows);
// Step 5: Copy this entire code snippet, paste it to the JavaScript console,
// and press Enter to run; all photos and videos will be downloaded
// to your default Downloads folder and they should have proper
// file names.
//
// Repeat Steps 3 and 5 to download photos and videos for another month.
(function() {
var e = document.createElement('script');
e.src = 'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js';
e.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(e);
var run = function(callback) {
if (window.jQuery) {
callback(jQuery);
} else {
window.setTimeout(function() { run(callback); }, 100);
}
};
run(function($) {
var year = '';
$('.tile.pointable:not([id])').each(function() {
if ($(this).attr('style') === 'background-color: rgb(250, 167, 50);') {
year = $(this).find('span').text().slice(3, 7);
}
});
var date = '', seq = 0;
$($('.tile.pointable[id]').get().reverse()).each(function() {
var s = $(this).find('.center h2 span');
if (s.length > 0) {
date = year + '-' + s.text().split('/').map(padToTwo).join('-');
seq = 1;
return;
}
var style = $(this).attr('style');
if (typeof style === typeof undefined || style === false) {
return;
}
var url = style.replace('background-image: url("', '')
.replace('thumbnail=true&', '')
.replace('");', '');
var basename = date + '-' + padToTwo(String(seq)),
ext = $(this).find('.play-icon').length > 0 ? 'mp4' : 'jpg';
var e = document.createElement('a');
e.href = url;
e.download = basename + '.' + ext;
document.body.appendChild(e);
e.click();
document.body.removeChild(e);
seq += 1;
});
function padToTwo(s) {
return s.length >= 2 ? s : Array(2 - s.length + 1).join('0') + s;
}
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment